답안 #1114417

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1114417 2024-11-18T20:20:43 Z MrAndria Zagrade (COI20_zagrade) C++14
100 / 100
1951 ms 1612 KB
#include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define pb push_back
//#define int long long
int n,q;
char c[1000005];
vector <int> v;
bool b1;
bool query(int l,int r){
    cout<<"? "<<l<<" "<<r<<endl;
    bool b2;
    cin>>b2;
    return b2;
}
int main(){
    cin>>n>>q;
    // v.pb(1\);


    for(int i=1;i<=n;i++){
        v.pb(i);   
        if(v.size()<2){
            continue;
        }
        b1=query(v[v.size()-2],v[v.size()-1]);
        if(b1){
            c[v[v.size()-2]]='(';
            c[v[v.size()-1]]=')';
            v.pop_back();
            v.pop_back();
        }


        
    }
    if(v.size()){
        for(int i=1;i<=v.size();i++){
            if(2*i<=(v.size())){
                c[v[i-1]]=')';
            }else{
                c[v[i-1]]='(';
            }
        }
        cout<<"! ";
        for(int i=1;i<=n;i++){
            cout<<c[i];
        }
        cout<<endl;
    }else{
        cout<<"! ";
        for(int i=1;i<=n;i++){
            cout<<c[i];
        }
        cout<<endl;
    }
}

Compilation message

zagrade.cpp: In function 'int main()':
zagrade.cpp:39:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |         for(int i=1;i<=v.size();i++){
      |                     ~^~~~~~~~~~
zagrade.cpp:40:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   40 |             if(2*i<=(v.size())){
      |                ~~~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 8 ms 336 KB Output is correct
3 Correct 15 ms 336 KB Output is correct
4 Correct 13 ms 336 KB Output is correct
5 Correct 17 ms 336 KB Output is correct
6 Correct 18 ms 504 KB Output is correct
7 Correct 14 ms 336 KB Output is correct
8 Correct 10 ms 336 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 18 ms 512 KB Output is correct
3 Correct 18 ms 452 KB Output is correct
4 Correct 16 ms 584 KB Output is correct
5 Correct 16 ms 448 KB Output is correct
6 Correct 17 ms 448 KB Output is correct
7 Correct 15 ms 336 KB Output is correct
8 Correct 15 ms 336 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 929 ms 1020 KB Output is correct
3 Correct 1910 ms 988 KB Output is correct
4 Correct 1935 ms 1008 KB Output is correct
5 Correct 1951 ms 996 KB Output is correct
6 Correct 1892 ms 1280 KB Output is correct
7 Correct 1920 ms 1584 KB Output is correct
8 Correct 1897 ms 1008 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1925 ms 1500 KB Output is correct
3 Correct 1936 ms 1132 KB Output is correct
4 Correct 1912 ms 1316 KB Output is correct
5 Correct 1705 ms 868 KB Output is correct
6 Correct 1905 ms 1612 KB Output is correct
7 Correct 1901 ms 1216 KB Output is correct
8 Correct 1939 ms 1032 KB Output is correct