답안 #381469

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
381469 2021-03-25T08:18:29 Z Araragi Zagrade (COI20_zagrade) C++17
0 / 100
1 ms 364 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;

    map<int, bool> was;

    stack<int> st;
    int last = 1;
    st.push(last);
    was[last] = true;
    last++;
    string s = "";

    for (int i = 0; i < n; i++)
        s += 'a';

    while (!st.empty())
    {
        bool verdict = ask(st.top(), last);
        if (verdict)
        {
            s[st.top() - 1] = '(';
            s[last - 1] = ')';
            st.pop();
            if (st.empty() && last + 1 <= n)
            {
                st.push(last + 1);
                last++;
            }
        }
        else if (!verdict && last <= n)
        {
            st.push(last);
        }
        last++;
    }

    cout << "? " << s << 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();

}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 364 KB Expected integer, but "()" found
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 364 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 364 KB Expected integer, but "(())" found
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 364 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -