답안 #242926

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
242926 2020-06-29T20:39:04 Z MatesV13 Zagonetka (COI18_zagonetka) C++11
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;
long long n, x, starix, prvi, drugi;
vector<int> ansmin, ansmax, cur; 
int main (){
ios::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
cin >> n; 
for (int i=0; i<n; i++) cin >> x;
for (int i=1; i<=n; i++) cur.push_back(i);
ansmax.resize(n, 0);
if (n<7){
	do {
	cout << "query";
	for (int i=0; i<n; i++) cout << " " << cur[i];
	cout << endl << flush; cin >> x;
	if (x){
		if (ansmin.empty()) 
			ansmin=cur;
		ansmax=cur;
	}
	} while(next_permutation(cur.begin(), cur.end()));
	cout << "end" << endl;
	for (int i=0; i<n; i++) cout << ansmin[i] << " "; cout << endl;
	for (int i=0; i<n; i++) cout << ansmax[i] << " "; cout << endl << flush;
}
else {
	cout << "query";
	for (int i=0; i<n; i++) cout << " " << cur[i];
	cout << endl << flush; cin >> starix;
	for (int i=0; i<n-1; i++) swap(cur[i], cur[i+1]);
	for (int i=1; i<=n; i++){
		cout << "query";
		for (int i=0; i<n; i++) cout << " " << cur[i];
		cout << endl << flush; cin >> x;
		if (x==0 and starix==1) prvi=i;
		if (x==1 and starix==0) drugi=i;
		starix=x; for (int i=0; i<n-1; i++) swap(cur[i], cur[i+1]);
	}
	cout << "end" << endl;
//	cout << prvi << " " << drugi << endl;
	for (int i=1; i<=n; i++){
		if (i==drugi and drugi<prvi) continue;
		else if (i==prvi and drugi<prvi) cout << prvi << " " << drugi << " ";
		else cout << i << " ";
	} cout << endl;
	for (int i=n; i>0; i--){
		if (i==drugi and prvii<drugi) continue;
		else if (i==prvi and prvi<drugi) cout << prvi << " " << drugi << " ";
		else cout << i << " ";
	} cout << endl << flush; 
}
return 0;
}

Compilation message

zagonetka.cpp: In function 'int main()':
zagonetka.cpp:24:2: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
  for (int i=0; i<n; i++) cout << ansmin[i] << " "; cout << endl;
  ^~~
zagonetka.cpp:24:52: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
  for (int i=0; i<n; i++) cout << ansmin[i] << " "; cout << endl;
                                                    ^~~~
zagonetka.cpp:25:2: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
  for (int i=0; i<n; i++) cout << ansmax[i] << " "; cout << endl << flush;
  ^~~
zagonetka.cpp:25:52: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
  for (int i=0; i<n; i++) cout << ansmax[i] << " "; cout << endl << flush;
                                                    ^~~~
zagonetka.cpp:48:20: error: 'prvii' was not declared in this scope
   if (i==drugi and prvii<drugi) continue;
                    ^~~~~
zagonetka.cpp:48:20: note: suggested alternative: 'prvi'
   if (i==drugi and prvii<drugi) continue;
                    ^~~~~
                    prvi