답안 #748482

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
748482 2023-05-26T10:53:33 Z mariowong Zagrade (COI20_zagrade) C++14
100 / 100
1078 ms 916 KB
#include <bits/stdc++.h>

using namespace std;

int n,q,ct,x,l,r;
char s[100005];
stack <int> st;
int main(){
	scanf("%d%d",&n,&q);
	st.push(1);
	for (int i=2;i<=n;i++){
		if (!st.empty()){
			printf("? %d %d\n",st.top(),i);
			fflush(stdout);
			scanf("%d",&x);
			if (x == 1){
				s[st.top()]='(';
				s[i]=')';
				st.pop();
				ct++;
			}
			else
			st.push(i);
		}
		else
		st.push(i);
	}
	printf("! ");
	for (int i=1;i<=n;i++){
		if (ct < n/2 && s[i] != ')' && s[i] != '('){
			s[i]=')';
			ct++;
		}
		else
		if (s[i] != '(' && s[i] != ')')
		s[i]='(';
	}
	for (int i=1;i<=n;i++){
		printf("%c",s[i]);
	}
	printf("\n");
	fflush(stdout);
	return 0;
}

Compilation message

zagrade.cpp: In function 'int main()':
zagrade.cpp:9:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    9 |  scanf("%d%d",&n,&q);
      |  ~~~~~^~~~~~~~~~~~~~
zagrade.cpp:15:9: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |    scanf("%d",&x);
      |    ~~~~~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 208 KB Output is correct
2 Correct 4 ms 208 KB Output is correct
3 Correct 9 ms 208 KB Output is correct
4 Correct 6 ms 208 KB Output is correct
5 Correct 5 ms 208 KB Output is correct
6 Correct 9 ms 208 KB Output is correct
7 Correct 11 ms 208 KB Output is correct
8 Correct 9 ms 208 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 11 ms 208 KB Output is correct
3 Correct 8 ms 208 KB Output is correct
4 Correct 10 ms 296 KB Output is correct
5 Correct 9 ms 208 KB Output is correct
6 Correct 10 ms 208 KB Output is correct
7 Correct 8 ms 208 KB Output is correct
8 Correct 10 ms 208 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 208 KB Output is correct
2 Correct 408 ms 440 KB Output is correct
3 Correct 819 ms 592 KB Output is correct
4 Correct 694 ms 476 KB Output is correct
5 Correct 867 ms 624 KB Output is correct
6 Correct 851 ms 504 KB Output is correct
7 Correct 870 ms 596 KB Output is correct
8 Correct 753 ms 380 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 1078 ms 916 KB Output is correct
3 Correct 720 ms 532 KB Output is correct
4 Correct 1018 ms 564 KB Output is correct
5 Correct 991 ms 552 KB Output is correct
6 Correct 923 ms 584 KB Output is correct
7 Correct 963 ms 520 KB Output is correct
8 Correct 634 ms 364 KB Output is correct