Submission #1099112

# Submission time Handle Problem Language Result Execution time Memory
1099112 2024-10-10T15:02:51 Z lomta Zagrade (COI20_zagrade) C++17
100 / 100
1290 ms 3136 KB
#include <bits/stdc++.h>
using namespace std;

const int MAXN=100005;

int arr[MAXN],hel;
int quest(int a,int b){

    cout<<"?"<<" "<< a<<" "<<b<<endl;
    int x;cin>>x;
    return x;

}
int main(){
    int n,m;cin>>n>>m;
    string s;
    for(int i=1;i<=n;i++){
        s=s+' ';

        if(hel==0 || !quest(arr[hel],i)){
            arr[++hel]=i;
        }
        else{
            s[arr[hel--]-1]='(';
            s[i-1]=')';
        }

    }

    for(int i=1;i<=hel/2;i++){
        s[arr[i]-1]=')';
    }
    for(int i=hel/2+1;i<=hel;i++){
        s[arr[i]-1]='(';
    }

    cout<< " ! " <<s;

}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 2 ms 344 KB Output is correct
3 Correct 5 ms 344 KB Output is correct
4 Correct 6 ms 600 KB Output is correct
5 Correct 5 ms 344 KB Output is correct
6 Correct 6 ms 456 KB Output is correct
7 Correct 6 ms 344 KB Output is correct
8 Correct 5 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 6 ms 484 KB Output is correct
3 Correct 5 ms 344 KB Output is correct
4 Correct 7 ms 344 KB Output is correct
5 Correct 9 ms 344 KB Output is correct
6 Correct 7 ms 344 KB Output is correct
7 Correct 5 ms 344 KB Output is correct
8 Correct 5 ms 600 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 870 ms 2792 KB Output is correct
3 Correct 1153 ms 1720 KB Output is correct
4 Correct 1160 ms 3136 KB Output is correct
5 Correct 1235 ms 1592 KB Output is correct
6 Correct 1217 ms 1384 KB Output is correct
7 Correct 1243 ms 1604 KB Output is correct
8 Correct 1148 ms 1412 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1176 ms 1812 KB Output is correct
3 Correct 1278 ms 1540 KB Output is correct
4 Correct 1290 ms 1660 KB Output is correct
5 Correct 1218 ms 1784 KB Output is correct
6 Correct 1202 ms 1720 KB Output is correct
7 Correct 1150 ms 1512 KB Output is correct
8 Correct 1273 ms 1148 KB Output is correct