Submission #1003775

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

Compilation message

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 time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 2 ms 344 KB Output is correct
3 Correct 4 ms 344 KB Output is correct
4 Correct 6 ms 344 KB Output is correct
5 Correct 6 ms 344 KB Output is correct
6 Correct 6 ms 344 KB Output is correct
7 Correct 6 ms 436 KB Output is correct
8 Correct 4 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 5 ms 344 KB Output is correct
3 Correct 5 ms 344 KB Output is correct
4 Correct 5 ms 440 KB Output is correct
5 Correct 6 ms 344 KB Output is correct
6 Correct 5 ms 344 KB Output is correct
7 Correct 5 ms 344 KB Output is correct
8 Correct 4 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 276 ms 600 KB Output is correct
3 Correct 620 ms 600 KB Output is correct
4 Correct 578 ms 600 KB Output is correct
5 Correct 578 ms 600 KB Output is correct
6 Correct 575 ms 600 KB Output is correct
7 Correct 565 ms 1364 KB Output is correct
8 Correct 592 ms 600 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 529 ms 1752 KB Output is correct
3 Correct 570 ms 1372 KB Output is correct
4 Correct 565 ms 1440 KB Output is correct
5 Correct 588 ms 1124 KB Output is correct
6 Correct 603 ms 1604 KB Output is correct
7 Correct 592 ms 1340 KB Output is correct
8 Correct 531 ms 600 KB Output is correct