Submission #585050

# Submission time Handle Problem Language Result Execution time Memory
585050 2022-06-28T09:28:11 Z MetalPower Zagrade (COI20_zagrade) C++14
100 / 100
872 ms 1020 KB
#include <bits/stdc++.h>
using namespace std;

int query(int l, int r){
	cout << "? " << l + 1 << " " << r + 1 << endl;
	int q; cin >> q; return q;
}

int N, Q;
vector<int> st;
vector<char> v;

int main(){

	cin >> N >> Q;
	v.resize(N, '-');

	for(int i = 0; i < N; i++){
		if(!st.empty()){
			if(query(st.back(), i) == 1){
				v[st.back()] = '(', v[i] = ')';
				st.pop_back();
			}else{
				st.push_back(i);
			}
		}else{
			st.push_back(i);
		}
	}

	for(int i = 0; i < st.size() / 2; i++) v[st[i]] = ')';
	for(int i = st.size() / 2; i < st.size(); i++) v[st[i]] = '(';

	cout << "! ";
	for(int i = 0; i < N; i++) cout << v[i];
	cout << endl;
}

Compilation message

zagrade.cpp: In function 'int main()':
zagrade.cpp:31:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |  for(int i = 0; i < st.size() / 2; i++) v[st[i]] = ')';
      |                 ~~^~~~~~~~~~~~~~~
zagrade.cpp:32:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |  for(int i = st.size() / 2; i < st.size(); i++) v[st[i]] = '(';
      |                             ~~^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 228 KB Output is correct
2 Correct 7 ms 208 KB Output is correct
3 Correct 9 ms 208 KB Output is correct
4 Correct 7 ms 208 KB Output is correct
5 Correct 4 ms 208 KB Output is correct
6 Correct 9 ms 256 KB Output is correct
7 Correct 4 ms 208 KB Output is correct
8 Correct 8 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 9 ms 208 KB Output is correct
3 Correct 10 ms 296 KB Output is correct
4 Correct 9 ms 280 KB Output is correct
5 Correct 10 ms 296 KB Output is correct
6 Correct 6 ms 296 KB Output is correct
7 Correct 6 ms 208 KB Output is correct
8 Correct 6 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 346 ms 380 KB Output is correct
3 Correct 872 ms 380 KB Output is correct
4 Correct 789 ms 376 KB Output is correct
5 Correct 634 ms 464 KB Output is correct
6 Correct 760 ms 396 KB Output is correct
7 Correct 669 ms 764 KB Output is correct
8 Correct 479 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Output is correct
2 Correct 782 ms 1020 KB Output is correct
3 Correct 659 ms 584 KB Output is correct
4 Correct 740 ms 804 KB Output is correct
5 Correct 485 ms 564 KB Output is correct
6 Correct 846 ms 760 KB Output is correct
7 Correct 726 ms 728 KB Output is correct
8 Correct 859 ms 336 KB Output is correct