Submission #593519

# Submission time Handle Problem Language Result Execution time Memory
593519 2022-07-11T10:14:41 Z jiahng Zagrade (COI20_zagrade) C++14
71 / 100
786 ms 912 KB
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
#define int ll
typedef pair<int,ll> pi;
typedef vector <int> vi;
typedef vector <pi> vpi;
typedef pair<pi, ll> pii;
typedef set <ll> si;
typedef long double ld;
#define f first
#define s second
#define mp make_pair
#define FOR(i,s,e) for(int i=s;i<=int(e);++i)
#define DEC(i,s,e) for(int i=s;i>=int(e);--i)
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
#define aFOR(i,x) for (auto i: x)
#define mem(x,i) memset(x,i,sizeof x)
#define fast ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define maxn 500100
#define INF (ll)1e14
#define MOD 1000000007
#define getchar_unlocked _getchar_nolock

int N,Q;
char ans[maxn];

bool qry(int a,int b){
    cout << "? " << a << ' ' << b << '\n';
    cout.flush();
    bool res; cin >> res;
    return res;
}
int32_t main(){
    fast;
    cin >> N >> Q;
    stack <int> st; st.push(1);
    FOR(i,2,N){
        if (!st.empty() && qry(st.top(), i)){
            ans[i] = ')'; ans[st.top()] = '('; st.pop();
        }else st.push(i);
    }
    FOR(i,1,st.size()){
        ans[st.top()] = (i <= st.size() / 2 ? '(' : ')'); st.pop();
    }
    cout << "! "; FOR(i,1,N) cout << ans[i]; cout << '\n';
    cout.flush();
}

Compilation message

zagrade.cpp: In function 'int32_t main()':
zagrade.cpp:48:28: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::stack<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   48 |         ans[st.top()] = (i <= st.size() / 2 ? '(' : ')'); st.pop();
      |                          ~~^~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 412 KB Output is correct
2 Correct 4 ms 208 KB Output is correct
3 Correct 10 ms 208 KB Output is correct
4 Correct 7 ms 208 KB Output is correct
5 Correct 5 ms 324 KB Output is correct
6 Correct 8 ms 208 KB Output is correct
7 Correct 6 ms 208 KB Output is correct
8 Correct 7 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 208 KB Mismatch at position 1. Expected ), found
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 456 ms 464 KB Output is correct
3 Correct 786 ms 748 KB Output is correct
4 Correct 663 ms 612 KB Output is correct
5 Correct 717 ms 516 KB Output is correct
6 Correct 630 ms 508 KB Output is correct
7 Correct 671 ms 912 KB Output is correct
8 Correct 745 ms 524 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 208 KB Mismatch at position 1. Expected ), found
2 Halted 0 ms 0 KB -