답안 #781297

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
781297 2023-07-13T02:13:13 Z andecaandeci Zagrade (COI20_zagrade) C++17
71 / 100
747 ms 772 KB
#include<bits/stdc++.h>

using namespace std;

#define fi first
#define se second
#define pii pair<int,int>
#define pll pair<long long, long long>

int n,q,sisa;
stack<int> st;
char s[100069];

int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int i,j;
    cin>>n>>q;
    sisa = n/2;
    for(i=1;i<=n and q;i++)
    {
        if(st.empty())
        {
            st.push(i);
            continue;
        }
        cout<<"? "<<st.top()<<" "<<i<<'\n';
        cout.flush();
        bool valid;
        cin>>valid;
        if(valid)
        {
            s[st.top()] = '(';
            s[i] = ')';
            sisa--;
            st.pop();
        }
        else
        {
            st.push(i);
        }
        q--;
    }
    for(j=i;j<=n;j++) st.push(j);
    while(!st.empty())
    {
        int x = st.top();
        st.pop();
        if(sisa)
        {
            s[x] = ')';
            sisa--;
        }
        else
        {
            s[x] = '(';
        }
    }
    cout<<"! ";
    for(i=1;i<=n;i++)
    {
        cout<<s[i];
        if(i == n)
        {
            cout<<'\n';
        }
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 208 KB Output is correct
2 Correct 4 ms 208 KB Output is correct
3 Correct 9 ms 208 KB Output is correct
4 Correct 10 ms 208 KB Output is correct
5 Correct 7 ms 208 KB Output is correct
6 Correct 8 ms 208 KB Output is correct
7 Correct 8 ms 208 KB Output is correct
8 Correct 8 ms 208 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 208 KB Mismatch at position 1. Expected ), found (
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 208 KB Output is correct
2 Correct 283 ms 468 KB Output is correct
3 Correct 610 ms 400 KB Output is correct
4 Correct 531 ms 444 KB Output is correct
5 Correct 491 ms 484 KB Output is correct
6 Correct 632 ms 488 KB Output is correct
7 Correct 747 ms 772 KB Output is correct
8 Correct 721 ms 476 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 208 KB Mismatch at position 1. Expected ), found (
2 Halted 0 ms 0 KB -