답안 #780781

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
780781 2023-07-12T13:04:55 Z kebine Zagrade (COI20_zagrade) C++17
0 / 100
1 ms 208 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,q;
char ans[200005];
ll jumopen,jumclose;
int main(){
    // ios_base::sync_with_stdio(0); cin.tie(0);
    cin>>n>>q;
    ll x=2;
    vector <ll> tumpuk;
    for (int i=1;i<=n;i++) ans[i]=' ';
    tumpuk.push_back(1);
    ll y;
    for (int i=2;i<=n;i++){
        if (tumpuk.empty()){
            tumpuk.push_back(i);
            continue;
        }
        cout<<">>> ? "<<tumpuk[tumpuk.size()-1]<<" "<<i<<endl;
        // fflush(stdout);
        cin>>y;
        if (y==0){
            tumpuk.push_back(i);
        }
        else{
            ans[tumpuk[tumpuk.size()-1]]='(';
            ans[i]=')';
            jumopen++;
            jumclose++;
            tumpuk.pop_back();
        }
    }
    ll u=ceil((long double)n/2)-jumopen;
    cout<<">>> ! ";
    // fflush(stdout);
    for (int i=1;i<=n;i++){
        if (ans[i]!=' ') {
            cout<<ans[i];
            // fflush(stdout);
        }
        else if (u!=0){
            cout<<")";
            // fflush(stdout);
            u--;
        }
        else{
            cout<<"(";
            // fflush(stdout);
        }
    }
}

Compilation message

zagrade.cpp: In function 'int main()':
zagrade.cpp:10:8: warning: unused variable 'x' [-Wunused-variable]
   10 |     ll x=2;
      |        ^
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 208 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 0 ms 208 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 0 ms 208 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 0 ms 208 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -