Submission #1003769

# Submission time Handle Problem Language Result Execution time Memory
1003769 2024-06-20T17:20:28 Z vjudge1 Zagrade (COI20_zagrade) C++17
100 / 100
632 ms 2224 KB
#include<bits/stdc++.h>
using namespace std;

#define N 200010
#define INFLL 2000000000000000020
#define pb push_back

typedef long long ll;
typedef pair<ll,ll> pll;

vector<ll>pos;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
    ll n,q,i=1,sz;
    string ans=" ";
    bool ret;

    cin >> n >> q;
    for(i=1;i<=n;i++)
    {
        ans+="(";
    }
    i=1;
    while(i<=n)
    {
        if(pos.empty())
        {
            pos.pb(i);
            i++;
            continue;
        }
        cout << "? " << pos.back() << " " << i << endl;
        fflush(stdout);
        cin >> ret;
        if(ret)
        {
            ans[i]=')';
            pos.pop_back();
        }else
        {
            pos.pb(i);
        }
        i++;
    }
    sz=(ll)(pos.size());
    for(i=0;i<sz/2;i++)
        ans[pos[i]]=')';
    cout << "!" << ans << endl;
    fflush(stdout);

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 3 ms 344 KB Output is correct
3 Correct 5 ms 428 KB Output is correct
4 Correct 5 ms 344 KB Output is correct
5 Correct 5 ms 344 KB Output is correct
6 Correct 4 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 0 ms 344 KB Output is correct
2 Correct 4 ms 464 KB Output is correct
3 Correct 6 ms 460 KB Output is correct
4 Correct 4 ms 344 KB Output is correct
5 Correct 4 ms 344 KB Output is correct
6 Correct 6 ms 344 KB Output is correct
7 Correct 6 ms 600 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 263 ms 644 KB Output is correct
3 Correct 632 ms 708 KB Output is correct
4 Correct 510 ms 648 KB Output is correct
5 Correct 517 ms 652 KB Output is correct
6 Correct 561 ms 644 KB Output is correct
7 Correct 544 ms 1264 KB Output is correct
8 Correct 565 ms 644 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 549 ms 2224 KB Output is correct
3 Correct 534 ms 1816 KB Output is correct
4 Correct 558 ms 1988 KB Output is correct
5 Correct 563 ms 1476 KB Output is correct
6 Correct 559 ms 1660 KB Output is correct
7 Correct 513 ms 1576 KB Output is correct
8 Correct 512 ms 644 KB Output is correct