Submission #411946

# Submission time Handle Problem Language Result Execution time Memory
411946 2021-05-26T10:22:11 Z 반딧불(#7584) Zagrade (COI20_zagrade) C++17
0 / 100
1 ms 200 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int n, q;
char arr[100002];
stack<int> stk;

int main(){
    scanf("%d %d", &n, &q);
    for(int i=1; i<=n; i++){
        if(stk.empty()) stk.push(i);
        else{
            printf("? %d %d\n", stk.top(), i);
            fflush(stdout);

            int ret;
            scanf("%d", &ret);
            if(!ret) stk.push(i);
            else{
                arr[stk.top()] = '(';
                arr[i] = ')';
                stk.pop();
            }
        }
    }

    int s = (int)stk.size() / 2;
    while((int)stk.size() > s){
        arr[stk.top()] = '(';
        stk.pop();
    }
    while(!stk.empty()){
        arr[stk.top()] = ')';
        stk.pop();
    }
    printf("%s", arr+1);
}

Compilation message

zagrade.cpp: In function 'int main()':
zagrade.cpp:12:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |     scanf("%d %d", &n, &q);
      |     ~~~~~^~~~~~~~~~~~~~~~~
zagrade.cpp:20:18: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   20 |             scanf("%d", &ret);
      |             ~~~~~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 200 KB Incorrect query ()
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 200 KB Incorrect query )(
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 200 KB Incorrect query (())
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 200 KB Incorrect query ))((
2 Halted 0 ms 0 KB -