답안 #1003755

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1003755 2024-06-20T16:51:45 Z vjudge1 Zagrade (COI20_zagrade) C++17
71 / 100
550 ms 1148 KB
#include <bits/stdc++.h>
using namespace std;

#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define mp make_pair

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef complex<double> cd;

const int MAXN = 1e5+10;
const int MOD = 1e9+7;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3f;
const double PI = acos(-1);

void solve(){
	int n, q; cin >> n >> q;
	
	stack<int> last;
	int curr=1;
	string res;
	
	while(curr<=n){
		if(last.empty()){
			res+='(';
			last.push(curr);
			curr++;
			continue;
		}
		
		cout << "? " << last.top() << " " << curr << endl;
		int aux; cin >> aux;
		
		if(aux){
			last.pop();
			res+=')';
		}
		else{
			last.push(curr);
			res+='(';
		}
		
		curr++;
	}
	
	cout << "! " << res << endl;
}

int32_t main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	
	int tt=1;
	//~ cin >> tt;
	while(tt--) solve();
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 3 ms 448 KB Output is correct
3 Correct 5 ms 344 KB Output is correct
4 Correct 4 ms 344 KB Output is correct
5 Correct 4 ms 344 KB Output is correct
6 Correct 4 ms 344 KB Output is correct
7 Correct 6 ms 456 KB Output is correct
8 Correct 5 ms 452 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB Mismatch at position 1. Expected ), found (
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 229 ms 892 KB Output is correct
3 Correct 550 ms 1064 KB Output is correct
4 Correct 429 ms 716 KB Output is correct
5 Correct 428 ms 648 KB Output is correct
6 Correct 408 ms 880 KB Output is correct
7 Correct 466 ms 1148 KB Output is correct
8 Correct 490 ms 1040 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB Mismatch at position 1. Expected ), found (
2 Halted 0 ms 0 KB -