답안 #411950

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
411950 2021-05-26T10:31:36 Z 송준혁(#7508) Zagrade (COI20_zagrade) C++17
100 / 100
1142 ms 1096 KB
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define lb lower_bound
#define MOD 1000000007
#define INF (1ll<<62)
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;

int N;
char ans[101010];
vector<int> S;

int main(){
	scanf("%d %*d", &N);
	S.pb(1);
	for (int i=2; i<=N; i++){
		if (S.empty()){
			S.pb(i);
			continue;
		}
		printf("? %d %d\n", S.back(), i);
		fflush(stdout);
		int x;
		scanf("%d", &x);
		if (x) ans[S.back()]='(', ans[i]=')', S.pop_back();
		else S.pb(i);
	}
	int t = S.size()/2;
	while (S.size() > t) ans[S.back()]='(', S.pop_back();
	while (S.size()) ans[S.back()]=')', S.pop_back();
	printf("! %s\n", ans+1);
	return 0;
}

Compilation message

zagrade.cpp: In function 'int main()':
zagrade.cpp:32:18: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   32 |  while (S.size() > t) ans[S.back()]='(', S.pop_back();
      |         ~~~~~~~~~^~~
zagrade.cpp:17:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   17 |  scanf("%d %*d", &N);
      |  ~~~~~^~~~~~~~~~~~~~
zagrade.cpp:27:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   27 |   scanf("%d", &x);
      |   ~~~~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 200 KB Output is correct
2 Correct 7 ms 200 KB Output is correct
3 Correct 13 ms 200 KB Output is correct
4 Correct 15 ms 200 KB Output is correct
5 Correct 10 ms 200 KB Output is correct
6 Correct 8 ms 200 KB Output is correct
7 Correct 9 ms 200 KB Output is correct
8 Correct 12 ms 200 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 200 KB Output is correct
2 Correct 5 ms 328 KB Output is correct
3 Correct 12 ms 292 KB Output is correct
4 Correct 9 ms 200 KB Output is correct
5 Correct 19 ms 300 KB Output is correct
6 Correct 17 ms 292 KB Output is correct
7 Correct 9 ms 200 KB Output is correct
8 Correct 13 ms 236 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 200 KB Output is correct
2 Correct 428 ms 448 KB Output is correct
3 Correct 1059 ms 368 KB Output is correct
4 Correct 1041 ms 496 KB Output is correct
5 Correct 1050 ms 588 KB Output is correct
6 Correct 999 ms 484 KB Output is correct
7 Correct 1025 ms 888 KB Output is correct
8 Correct 1142 ms 572 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 200 KB Output is correct
2 Correct 728 ms 1060 KB Output is correct
3 Correct 914 ms 820 KB Output is correct
4 Correct 988 ms 1096 KB Output is correct
5 Correct 672 ms 744 KB Output is correct
6 Correct 697 ms 916 KB Output is correct
7 Correct 524 ms 688 KB Output is correct
8 Correct 789 ms 476 KB Output is correct