# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
781294 | 2023-07-13T02:07:27 Z | makanhulia | Zagrade (COI20_zagrade) | C++17 | 645 ms | 680 KB |
#include<bits/stdc++.h> using namespace std; #define fi first #define se second #define pii pair<int,int> #define pll pair<long long, long long> int n,q,sisa; stack<int> st; char s[100069]; int main() { ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); int i,j; cin>>n>>q; sisa = n/2; for(i=1;i<=n;i++) { if(st.empty()) { st.push(i); continue; } cout<<"? "<<st.top()<<" "<<i<<'\n'; cout.flush(); bool valid; cin>>valid; if(valid) { s[st.top()] = '('; s[i] = ')'; sisa--; st.pop(); } else { st.push(i); } } while(!st.empty()) { int x = st.top(); st.pop(); if(sisa) { s[x] = ')'; sisa--; } else { s[x] = '('; } } cout<<"! "; for(i=1;i<=n;i++) { cout<<s[i]; if(i == n) { cout<<'\n'; } } }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 208 KB | Output is correct |
2 | Correct | 4 ms | 208 KB | Output is correct |
3 | Correct | 6 ms | 208 KB | Output is correct |
4 | Correct | 6 ms | 208 KB | Output is correct |
5 | Correct | 6 ms | 208 KB | Output is correct |
6 | Correct | 4 ms | 208 KB | Output is correct |
7 | Correct | 9 ms | 208 KB | Output is correct |
8 | Correct | 6 ms | 208 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 256 KB | Mismatch at position 1. Expected ), found ( |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 208 KB | Output is correct |
2 | Correct | 277 ms | 376 KB | Output is correct |
3 | Correct | 615 ms | 392 KB | Output is correct |
4 | Correct | 619 ms | 432 KB | Output is correct |
5 | Correct | 645 ms | 492 KB | Output is correct |
6 | Correct | 547 ms | 584 KB | Output is correct |
7 | Correct | 579 ms | 680 KB | Output is correct |
8 | Correct | 508 ms | 516 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 208 KB | Mismatch at position 1. Expected ), found ( |
2 | Halted | 0 ms | 0 KB | - |