답안 #329650

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
329650 2020-11-21T21:57:12 Z GioChkhaidze Zagrade (COI20_zagrade) C++14
100 / 100
1026 ms 1280 KB
#include <bits/stdc++.h>
 
using namespace std;
const int N=1e5+5;

char C_[N];
int n_,q_,x_,pr_[N],nx_[N];
 
int main () {
	cin>>n_>>q_; // ;(((((((((((((((((((((((((((((( qqqqqqq

	for (int i=1; i<=n_+3; i++) 
		nx_[i]=i+1,pr_[i]=i-1,C_[i]='.';
	
	int l_=1,r_=2,L_=l_,R_=r_,ans_=n_/2;
	while (1<=L_ && L_<=n_ && 1<=R_ && R_<=n_) {
		l_=L_,r_=R_;
		nx_[l_]=r_;
		pr_[r_]=l_;
		cout<<"? "<<l_<<" "<<r_<<endl;
		cin>>x_;
		if (x_) {
			--ans_;
			C_[l_]='(',C_[r_]=')';
			if (1<=pr_[l_]) L_=pr_[l_],R_=nx_[r_];
				else L_=nx_[r_],R_=nx_[nx_[r_]],pr_[L_]=0;
		}
			else L_=nx_[l_],R_=nx_[r_],pr_[L_]=l_;
	}
	
	for (int i=1; i<=n_; i++) 
		if (C_[i]=='.') {			
			if (ans_>0) 
				C_[i]=')',--ans_;
					else 
				C_[i]='(';
		}
	
	cout<<"! ";
	for (int i=1; i<=n_; i++) 
		cout<<C_[i];
		cout<<endl;
}

Compilation message

zagrade.cpp: In function 'int main()':
zagrade.cpp:40:2: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   40 |  for (int i=1; i<=n_; i++)
      |  ^~~
zagrade.cpp:42:3: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   42 |   cout<<endl;
      |   ^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 364 KB Output is correct
2 Correct 5 ms 364 KB Output is correct
3 Correct 7 ms 364 KB Output is correct
4 Correct 11 ms 364 KB Output is correct
5 Correct 10 ms 364 KB Output is correct
6 Correct 9 ms 364 KB Output is correct
7 Correct 10 ms 364 KB Output is correct
8 Correct 9 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 6 ms 364 KB Output is correct
3 Correct 9 ms 364 KB Output is correct
4 Correct 8 ms 364 KB Output is correct
5 Correct 10 ms 364 KB Output is correct
6 Correct 9 ms 364 KB Output is correct
7 Correct 10 ms 364 KB Output is correct
8 Correct 11 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 364 KB Output is correct
2 Correct 365 ms 1132 KB Output is correct
3 Correct 847 ms 1132 KB Output is correct
4 Correct 834 ms 1280 KB Output is correct
5 Correct 755 ms 1132 KB Output is correct
6 Correct 720 ms 1132 KB Output is correct
7 Correct 793 ms 1132 KB Output is correct
8 Correct 874 ms 1132 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 492 KB Output is correct
2 Correct 764 ms 1132 KB Output is correct
3 Correct 857 ms 1132 KB Output is correct
4 Correct 980 ms 1132 KB Output is correct
5 Correct 891 ms 1260 KB Output is correct
6 Correct 987 ms 1132 KB Output is correct
7 Correct 1026 ms 1132 KB Output is correct
8 Correct 866 ms 1132 KB Output is correct