답안 #1034296

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1034296 2024-07-25T11:56:02 Z Luvidi Zagrade (COI20_zagrade) C++17
100 / 100
586 ms 1744 KB
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define pll pair<ll, ll>
#define pii pair<int, int>
#define fs first
#define sc second
#define pb push_back

void solve() {
    int n,q;
    cin>>n>>q;
    string ans;
    for(int i=1;i<=n;i++)ans+='.';
    vector<int> v;
    for(int i=1;i<=n;i++){
        v.pb(i);
        if(v.size()==1)continue;
        int x=v.size();
        cout<<"? "<<v[x-2]<<' '<<v[x-1]<<endl;
        bool b;
        cin>>b;
        if(b){
            ans[v[x-2]-1]='(';
            ans[v[x-1]-1]=')';
            v.pop_back();
            v.pop_back();
        }
    }
    for(int i=0;i<v.size()/2;i++)ans[v[i]-1]=')';
    for(int i=v.size()/2;i<v.size();i++)ans[v[i]-1]='(';
    cout<<"! "<<ans;
}

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

    solve();
}

Compilation message

zagrade.cpp: In function 'void solve()':
zagrade.cpp:31:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |     for(int i=0;i<v.size()/2;i++)ans[v[i]-1]=')';
      |                 ~^~~~~~~~~~~
zagrade.cpp:32:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |     for(int i=v.size()/2;i<v.size();i++)ans[v[i]-1]='(';
      |                          ~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 5 ms 344 KB Output is correct
4 Correct 4 ms 344 KB Output is correct
5 Correct 4 ms 344 KB Output is correct
6 Correct 4 ms 344 KB Output is correct
7 Correct 6 ms 344 KB Output is correct
8 Correct 4 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 4 ms 344 KB Output is correct
3 Correct 4 ms 344 KB Output is correct
4 Correct 5 ms 344 KB Output is correct
5 Correct 4 ms 344 KB Output is correct
6 Correct 6 ms 344 KB Output is correct
7 Correct 6 ms 600 KB Output is correct
8 Correct 4 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 297 ms 648 KB Output is correct
3 Correct 531 ms 652 KB Output is correct
4 Correct 528 ms 648 KB Output is correct
5 Correct 543 ms 644 KB Output is correct
6 Correct 584 ms 652 KB Output is correct
7 Correct 586 ms 984 KB Output is correct
8 Correct 536 ms 648 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 514 ms 1600 KB Output is correct
3 Correct 529 ms 1284 KB Output is correct
4 Correct 574 ms 1744 KB Output is correct
5 Correct 582 ms 964 KB Output is correct
6 Correct 531 ms 1340 KB Output is correct
7 Correct 560 ms 1228 KB Output is correct
8 Correct 538 ms 644 KB Output is correct