Notice
Recent Posts
Recent Comments
Link
«   2026/06   »
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30
Archives
Today
Total
관리 메뉴

dh-winternagi 님의 블로그

(27312) 운영진에게 설정 짜기는 어려워 본문

백준 (C++)/Solve

(27312) 운영진에게 설정 짜기는 어려워

dh-winternagi 2026. 4. 22. 23:45

https://www.acmicpc.net/problem/27312

단계별로 풀어보기

41단계(인터랙티브와 투 스텝 1) 1번째

 

 

 

칸토어의 대각선 논법을 떠올리면 되는 문제.

1번 캐릭터와 1번 속성이 다르고, 2번 캐릭터와 2번 속성이 다르고, ... , M번 캐릭터와 M번 속성이 다르면

이 새로운 캐릭터는 어떤 캐릭터와도 겹치지 않는다.

 

 

 

#include <iostream>
#include <vector>
using namespace std;

int main() 
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  
  int resp, m, n, q;
  
  cin >> m >> n >> q;
  
  vector<int> a(n+1), ans(n+1, 1);
  
  for(int i=1;i<=n;i++) cin >> a[i];
  
  for(int i=1;i<=m;i++){
    cout << "? " << i << " " << i << endl;
    cin >> resp;
    
    ans[i]= (resp==a[i])?1:resp+1;
  }
  
  cout << "! ";
  for(int i=1;i<=n;i++) cout << ans[i] << " ";
  
  return 0;
}

'백준 (C++) > Solve' 카테고리의 다른 글

(23435) Cloud computing  (0) 2026.04.23
(25672) Even and Odd Combinations  (0) 2026.04.22
(23306) binary는 호남선  (0) 2026.04.22
(19554) Guess the number  (0) 2026.04.22
(31430) A+B - 투 스텝  (0) 2026.04.22