제출 #1003775

#제출 시각아이디문제언어결과실행 시간메모리
1003775vjudge1Zagrade (COI20_zagrade)C++17
100 / 100
620 ms1752 KiB
#include <bits/stdc++.h>
using namespace std;

int query( int a, int b ){
  cout << "? " << a << " " << b << endl;
  int x; cin >> x; return x;
}

int main(){
  int n, q; cin >> n >> q;
  stack<int> pilha;
  vector<int> resp(n + 1);
  for( int i = 1; i <= n; i++ ){
    if( pilha.empty() ){
      pilha.push(i);
      continue;
    }
    if( query( pilha.top(), i ) ){
      resp[i] = -1;
      resp[pilha.top()] = 1;
      pilha.pop();
    }
    else pilha.push(i);
  }
  int tam = pilha.size()/2;
  while(tam--){ resp[pilha.top()] = 1; pilha.pop(); }
  while(!pilha.empty()){ resp[pilha.top()] = -1; pilha.pop(); }
  cout << "! ";
  for( int i = 1; i <= n; i++ ) cout << (( resp[i] == 1 ) ? "(" : ")" ); cout << endl;
}

컴파일 시 표준 에러 (stderr) 메시지

zagrade.cpp: In function 'int main()':
zagrade.cpp:29:3: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   29 |   for( int i = 1; i <= n; i++ ) cout << (( resp[i] == 1 ) ? "(" : ")" ); cout << endl;
      |   ^~~
zagrade.cpp:29:74: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   29 |   for( int i = 1; i <= n; i++ ) cout << (( resp[i] == 1 ) ? "(" : ")" ); cout << endl;
      |                                                                          ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...