Submission #967297

# Submission time Handle Problem Language Result Execution time Memory
967297 2024-04-21T18:16:27 Z mdobric Zagonetka (COI18_zagonetka) C++11
9 / 100
4 ms 440 KB
#include <bits/stdc++.h>
using namespace std;

int n, p[105];
int a[10];
vector <int> ans1, ans2;

int main (void){
	
	cin >> n;
	for (int i = 0; i < n; i++){
		cin >> p[i];
		a[i] = i + 1;
	}
	if (n <= 6){
		do{
			cout << "query ";
			for (int i = 0; i < n; i++){
				cout << a[i] << " ";
			}
			cout << endl;
			cout.flush();
			int ans;
			cin >> ans;
			if (ans == 1){
				if (ans1.size() == 0){
					for (int i = 0; i < n; i++){
						ans1.push_back(a[i]); 
					}
				}
				ans2.clear();
				for (int i = 0; i < n; i++){
					ans2.push_back(a[i]); 
				}
			}
		}while(next_permutation(a, a + n));
		cout << "end" << endl;
		for (int i = 0; i < n; i++){
			cout << ans1[i] << " ";
		}
		cout << endl;
		cout.flush();
		for (int i = 0; i < n; i++){
			cout << ans2[i] << " ";
		}
		cout << endl;
		cout.flush();
	}
	else{
		int x = -1, y;
		for (int i = 0; i < n; i++){
			for (int novi_pos = i + 1; novi_pos < n; novi_pos++){
			
				cout << "query ";
				for (int j = 0; j < i; j++){
					cout << p[j] << " ";
				}
				for (int j = i + 1; j <= novi_pos; j++){
					cout << p[j] << " ";
				}
				cout << p[i] << " ";
				for (int j = novi_pos + 1; j < n; j++){
					cout << p[j] << " ";
				}
				cout << endl;
				cout.flush();
				int ans;
				cin >> ans;
				if (ans == 1){
					x = i;
					y = novi_pos;
					break;
				}
				
			}
			if (x != -1){
				break;
			}
		}
		cout << "end" << endl;
		if (p[y] < p[x]){
			//cout << "aaa" << endl;
			for (int i = 1; i <= n; i++){
				cout << i << " ";
			}
			cout << endl;
			cout.flush();
			int manje = 0;
			for (int i = 0; i < n; i++){
				if (i == x){
					manje = 1;
				}
				
				if (i == y){
					cout << n - x << " ";
					manje = 0;
				}
				else{
					cout << n - i - manje << " ";
				}
			}
			cout << endl;
			cout.flush();
		}
		else{
			//cout << "aaa" << endl;
			int manje = 0;
			for (int i = 0; i < n; i++){
				if (i == x){
					manje = 1;
				}
				
				if (i == y){
					cout << x + 1 << " ";
					manje = 0;
				}
				else{
					cout << i + manje + 1 << " ";
				}
			}
			cout << endl;
			cout.flush();
			for (int i = 1; i <= n; i++){
				cout << n - i + 1 << " ";
			}
			cout << endl;
			cout.flush();
			
			//cout << "aaa" << endl;
		}
		
	}
	//cout << "bbb" << endl;
	
	return 0;
}

Compilation message

zagonetka.cpp: In function 'int main()':
zagonetka.cpp:81:10: warning: 'y' may be used uninitialized in this function [-Wmaybe-uninitialized]
   81 |   if (p[y] < p[x]){
      |       ~~~^
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 3 ms 344 KB Output is correct
6 Correct 4 ms 344 KB Output is correct
7 Correct 4 ms 372 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 0 ms 440 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 0 ms 440 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -