Submission #381416

# Submission time Handle Problem Language Result Execution time Memory
381416 2021-03-25T07:34:47 Z Araragi Zagrade (COI20_zagrade) C++17
0 / 100
822 ms 780 KB
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("00")
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int, int> pii;
ll time() {return chrono::system_clock().now().time_since_epoch().count();}
mt19937 rnd(time());
const int inf = 1e9;
const ll inf64 = 1e18;
#define ft first
#define fin(x) ifstream cin("x.in");
#define fout(x) ofstream cout("x.out");
#define sd second
#define pb push_back
#define sz(x) (int)x.size()

bool ask(int from, int to)
{
    int ans;
    cout << "? " << from << " " << to << endl;
    cin >> ans;
    return (ans == 1 ? true : false);
}

void solve()
{
    int n, k;
    cin >> n >> k;

    int last = 1;
    string ans = "";

    while (n > 0)
    {
        int siz = 2;
        while (1)
        {
            if (ask(last, last + siz - 1))
                break;

            siz++;
        }

        last += siz;

        for (int i = 0; i < siz; i++)
            if (i < (siz / 2))
            {
                ans += '(';
            }
            else
            {
                ans += ')';
            }

        n -= siz;
    }

    cout << "! " << ans << endl;
}

int main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    #ifdef _LOCAL_
        system("color 2");
    #endif // _LOCAL_

    int t = 1;

    while (t--)
        solve();

}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 4 ms 364 KB Output is correct
3 Incorrect 8 ms 364 KB Mismatch at position 9. Expected ), found (
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 364 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 526 ms 780 KB Output is correct
3 Incorrect 822 ms 652 KB Mismatch at position 15. Expected ), found (
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 364 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -