답안 #381399

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
381399 2021-03-25T07:24:22 Z Vimmer Zagrade (COI20_zagrade) C++14
0 / 100
3000 ms 4332 KB
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>

//#pragma GCC optimize("-O3")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC optimize("-Ofast")

#define N 200500
#define NN 1005000
#define PB push_back
//#define endl '\n'
#define pri(x) cout << x << endl
#define _ << " " <<
#define all(x) x.begin(), x.end()
#define sz(x) int(x.size())
#define M ll(1e9 + 7)
#define F first
#define S second

using namespace std;
//using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef short int si;
typedef unsigned long long ull;

//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

//ordered_set se;

void TL()
{
    while (1)
    {

    }
}

int n, q;

set <pair <int, int> > se;

int ask(int l, int r)
{
    if (se.find({l, r}) != se.end())
        TL();

    se.insert({l, r});

    q--;

    if (q == -1)
        TL();

    pri("?" _ l _ r);

    int x;

    cin >> x;

    return x;
}


char ans[N];

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

    //freopen("1.in", "r", stdin);

    cin >> n >> q;

    for (int i = 1; i <= n; i++)
        ans[i] = 'a';

    int kl = n;

    for (int i = 1; i <= n; i++)
    {
        if (i == n && kl > 0)
        {
            i = 0;

            continue;
        }

        if (ans[i] != 'a') continue;

        for (int j = i + 1; j <= n; j += 2)
        {
            if (ans[j] != 'a') continue;

            if (ask(i, j))
            {
                kl -= 2;

                ans[i] = '(';

                ans[j] = ')';
            }

            break;
        }
    }

    cout << "! ";

    for (int i = 1; i <= n; i++)
        cout << ans[i];

    cout << endl;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Execution timed out 3072 ms 364 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3061 ms 364 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 448 ms 2908 KB Output is correct
3 Execution timed out 3017 ms 4332 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3072 ms 364 KB Time limit exceeded
2 Halted 0 ms 0 KB -