답안 #318356

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
318356 2020-11-01T12:08:33 Z georgerapeanu Zagrade (COI20_zagrade) C++11
100 / 100
931 ms 1468 KB
#include <bits/stdc++.h>

using namespace std;

int query(int l,int r){
    int ans;

    cout << "? " << l << " " << r << endl;

    cin >> ans;
    
    return ans;
}

int main(){

    int n,q;

    cin >> n >> q;

    vector<int> v = {};

    string s = string(n,' ');

    for(int i = 1;i <= n;i++){
        if((int)v.size() < 1){
            v.push_back(i);
        }
        else if(query(v.back(),i) == 1){
            s[v.back() - 1] = '(';
            s[i - 1] = ')';
            v.pop_back();
        }
        else{
            v.push_back(i);
        }
    }

    for(int i = 0;i < (int)v.size();i++){
        if(2 * i < (int)v.size()){
            s[v[i] - 1] = ')';
        }
        else{
            s[v[i] - 1] = '(';
        }
    }

    cout << "! " <<  s << endl;

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 5 ms 364 KB Output is correct
3 Correct 11 ms 364 KB Output is correct
4 Correct 9 ms 256 KB Output is correct
5 Correct 10 ms 364 KB Output is correct
6 Correct 9 ms 364 KB Output is correct
7 Correct 9 ms 364 KB Output is correct
8 Correct 8 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 364 KB Output is correct
2 Correct 10 ms 364 KB Output is correct
3 Correct 9 ms 364 KB Output is correct
4 Correct 9 ms 492 KB Output is correct
5 Correct 9 ms 364 KB Output is correct
6 Correct 10 ms 364 KB Output is correct
7 Correct 9 ms 364 KB Output is correct
8 Correct 8 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 364 KB Output is correct
2 Correct 409 ms 468 KB Output is correct
3 Correct 788 ms 484 KB Output is correct
4 Correct 735 ms 516 KB Output is correct
5 Correct 843 ms 484 KB Output is correct
6 Correct 695 ms 476 KB Output is correct
7 Correct 931 ms 1068 KB Output is correct
8 Correct 848 ms 468 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 734 ms 1468 KB Output is correct
3 Correct 857 ms 868 KB Output is correct
4 Correct 802 ms 916 KB Output is correct
5 Correct 863 ms 1140 KB Output is correct
6 Correct 814 ms 824 KB Output is correct
7 Correct 772 ms 868 KB Output is correct
8 Correct 849 ms 484 KB Output is correct