Submission #986451

# Submission time Handle Problem Language Result Execution time Memory
986451 2024-05-20T15:06:19 Z alexdd Zagrade (COI20_zagrade) C++17
71 / 100
533 ms 2108 KB
#include<bits/stdc++.h>
using namespace std;
int n,q;
int query(int le, int ri)
{
    if((ri-le+1)%2==1)
        return 0;
    cout<<"? "<<le<<" "<<ri<<endl;
    int aux;
    cin>>aux;
    return aux;
}
char rez[100005];
signed main()
{
    cin>>n>>q;
    int cnt=n/2;
    deque<int> dq;
    for(int i=1;i<=n;i++)
    {
        dq.push_back(i);
        if((int)dq.size()>=2 && query(dq[(int)dq.size()-2],dq.back()))
        {
            rez[dq[(int)dq.size()-2]] = '(';
            rez[dq[(int)dq.size()-1]] = ')';
            dq.pop_back();
            dq.pop_back();
            cnt--;
        }
    }
    for(int i=1;i<=cnt;i++)
    {
        rez[i]=')';
        rez[n-i+1]='(';
    }
    cout<<"! ";
    for(int i=1;i<=n;i++)
        cout<<rez[i];
    cout<<endl;
    return 0;
}
# 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 4 ms 344 KB Output is correct
5 Correct 4 ms 344 KB Output is correct
6 Correct 4 ms 344 KB Output is correct
7 Correct 4 ms 440 KB Output is correct
8 Correct 5 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 4 ms 600 KB Output is correct
3 Incorrect 4 ms 344 KB Mismatch at position 1. Expected (, found )
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 259 ms 1740 KB Output is correct
3 Correct 485 ms 1516 KB Output is correct
4 Correct 502 ms 988 KB Output is correct
5 Correct 506 ms 992 KB Output is correct
6 Correct 500 ms 1232 KB Output is correct
7 Correct 527 ms 1560 KB Output is correct
8 Correct 520 ms 1236 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 533 ms 2108 KB Output is correct
3 Incorrect 532 ms 1548 KB Mismatch at position 1. Expected (, found )
4 Halted 0 ms 0 KB -