Submission #1018503

# Submission time Handle Problem Language Result Execution time Memory
1018503 2024-07-10T06:22:37 Z kukuk Zagrade (COI20_zagrade) C++14
0 / 100
1 ms 344 KB
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int ukr = 1e5+10;
ll n, m, id, a, b;
char ar[ukr];
vector<int> v;
int ask(int a, int b){
    cout << "? " << a << " " << b << endl;
    int kkl;
    cin >> kkl;
    return kkl;
}
void solve(){
    cin >> n >> m;
    for(int i = 1; i <= n; i++){
        ar[i] = '.';
    }
    ll pke = 0;
    for(int i = 1; i <= n; i++){
        if(v.empty()){
            v.push_back(i);
        }else{
            if(ask(v.back(), i)){
                ar[v.back()] = '(';
                ar[i] = ')';
                v.pop_back();
                pke += 2;
            }else{
                v.push_back(i);
            }
        }
    }
    pke = n-pke;
    pke/=2;
    for(int i = 1; i <= n; i++){
        if(ar[i] == '.'){
            if(!pke){
                ar[i] = '(';
            }else{
                pke--;
                ar[i] = ')';
            }
        }
        cout << ar[i];
    }
}
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();
    }
}
# 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 -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Incorrect query ))((
2 Halted 0 ms 0 KB -