제출 #781294

#제출 시각아이디문제언어결과실행 시간메모리
781294makanhuliaZagrade (COI20_zagrade)C++17
71 / 100
645 ms680 KiB
#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;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);
        }
    }
    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';
        }
    }
}

컴파일 시 표준 에러 (stderr) 메시지

zagrade.cpp: In function 'int main()':
zagrade.cpp:17:11: warning: unused variable 'j' [-Wunused-variable]
   17 |     int i,j;
      |           ^
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…