답안 #1003959

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1003959 2024-06-20T20:54:11 Z vjudge1 Zagrade (COI20_zagrade) C++17
100 / 100
621 ms 1960 KB
#include <bits/stdc++.h>

using namespace std;

int marc[100005];
stack<int> st;

int main(){
	int n,q; cin>>n>>q;

		for(int i = 1; i <= n; i++)marc[i] = -1;
		int qtd = 0;
		for(int i = 1; i <= n; i++){
			if(st.size() == 0){
				st.push(i);
				continue;
			}
			cout<<"? "<<st.top()<<" "<<i<<endl;
			int x; cin>>x;
			if(x == 1){
				qtd++;
				marc[st.top()] = 1;
				marc[i] = 0;
				st.pop();
			}else{
				st.push(i);
			}
		}

		for(int i = 1; i <= n; i++)
			if(marc[i] == -1){
				if(qtd < n/2){marc[i] = 0; qtd++;}
				else marc[i] = 1;
			}

		cout<<"! ";
		for(int i = 1; i <= n; i++){
			if(marc[i] == 0)cout<<")";
			else cout<<"(";
		}cout<<endl;
		return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 2 ms 344 KB Output is correct
3 Correct 5 ms 344 KB Output is correct
4 Correct 5 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 4 ms 344 KB Output is correct
8 Correct 4 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 6 ms 344 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 452 KB Output is correct
7 Correct 5 ms 344 KB Output is correct
8 Correct 6 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 308 ms 600 KB Output is correct
3 Correct 564 ms 600 KB Output is correct
4 Correct 605 ms 600 KB Output is correct
5 Correct 563 ms 600 KB Output is correct
6 Correct 587 ms 600 KB Output is correct
7 Correct 608 ms 1240 KB Output is correct
8 Correct 621 ms 600 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 579 ms 1896 KB Output is correct
3 Correct 522 ms 1360 KB Output is correct
4 Correct 534 ms 1960 KB Output is correct
5 Correct 506 ms 1128 KB Output is correct
6 Correct 507 ms 1408 KB Output is correct
7 Correct 477 ms 1396 KB Output is correct
8 Correct 493 ms 600 KB Output is correct