Submission #1003772

# Submission time Handle Problem Language Result Execution time Memory
1003772 2024-06-20T17:29:52 Z vjudge1 Zagrade (COI20_zagrade) C++17
0 / 100
1 ms 344 KB
#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(); }
  for( int i = 1; i <= n; i++ ) cout << (( resp[i] == 1 ) ? "(" : ")" ); cout << endl;
}

Compilation message

zagrade.cpp: In function 'int main()':
zagrade.cpp:28:3: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   28 |   for( int i = 1; i <= n; i++ ) cout << (( resp[i] == 1 ) ? "(" : ")" ); cout << endl;
      |   ^~~
zagrade.cpp:28:74: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   28 |   for( int i = 1; i <= n; i++ ) cout << (( resp[i] == 1 ) ? "(" : ")" ); cout << endl;
      |                                                                          ^~~~
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Incorrect query ()
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Incorrect query )(
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Incorrect query (())
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Incorrect query ))((
2 Halted 0 ms 0 KB -