답안 #706439

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
706439 2023-03-06T14:58:43 Z vjudge1 Zagrade (COI20_zagrade) C++14
100 / 100
888 ms 1444 KB
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FF first
#define SS second
#define all(a) a.begin(), a.end()
#define mod (ll)(1000000007)
bool ask(int l, int r){
    int val;
    cout<<"? "<<l<<' '<<r<<endl;
    cin>>val;
    return val;
}
int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);
    int n, q;
    cin>>n>>q;
    int a=n/2,b=n/2;
    vector<int>Ans(n+1), stk;
    for(int i=1;i<=n;i++){
        if(stk.empty()){
            stk.push_back(i);
        }
        else{
            bool val=ask(stk.back(), i);
            if(val){
                Ans[stk.back()]=1, Ans[i]=2;
                stk.pop_back();
                a--, b--;
            }
            else{
                stk.push_back(i);
            }
        }
    }
    cout<<"! ";
    for(int i=1;i<=n;i++){
        char c;
        if(Ans[i]){
            c='('+Ans[i]-1;
        }
        else{
            if(a)
                c=')', a--;
            else
                c='(';
        }
        cout<<c;
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 4 ms 208 KB Output is correct
3 Correct 10 ms 208 KB Output is correct
4 Correct 10 ms 208 KB Output is correct
5 Correct 6 ms 208 KB Output is correct
6 Correct 10 ms 208 KB Output is correct
7 Correct 9 ms 208 KB Output is correct
8 Correct 7 ms 208 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 8 ms 208 KB Output is correct
3 Correct 10 ms 308 KB Output is correct
4 Correct 8 ms 208 KB Output is correct
5 Correct 10 ms 336 KB Output is correct
6 Correct 7 ms 324 KB Output is correct
7 Correct 10 ms 208 KB Output is correct
8 Correct 7 ms 208 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 208 KB Output is correct
2 Correct 305 ms 700 KB Output is correct
3 Correct 836 ms 696 KB Output is correct
4 Correct 845 ms 720 KB Output is correct
5 Correct 683 ms 700 KB Output is correct
6 Correct 811 ms 708 KB Output is correct
7 Correct 703 ms 1064 KB Output is correct
8 Correct 865 ms 696 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 208 KB Output is correct
2 Correct 695 ms 1368 KB Output is correct
3 Correct 712 ms 1068 KB Output is correct
4 Correct 794 ms 1444 KB Output is correct
5 Correct 567 ms 896 KB Output is correct
6 Correct 888 ms 1244 KB Output is correct
7 Correct 846 ms 952 KB Output is correct
8 Correct 779 ms 712 KB Output is correct