답안 #242656

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
242656 2020-06-28T16:17:40 Z vanic Zagonetka (COI18_zagonetka) C++14
0 / 100
77 ms 384 KB
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <math.h>
#include <vector>
#include <set>

using namespace std;

const int maxn=105;

int p[maxn];
int q[maxn];
int pos[maxn];
vector < int > ms[2][maxn];
vector < int > val;

void siri(int x, bool s){
	val.push_back(p[x]);
	for(int i=0; i<ms[s][x].size(); i++){
		siri(ms[s][x][i], s);
	}
}

void gazi(int x, bool s){
	if(!s){
		q[x]=val.back();
		val.pop_back();
	}
	for(int i=0; i<ms[s][x].size(); i++){
		gazi(ms[s][x][i], s);
	}
	if(s){
		q[x]=val.back();
		val.pop_back();
	}
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n;
	cin >> n;
	for(int i=0; i<n; i++){
		cin >> p[i];
		pos[p[i]]=i;
	}
	bool prov;
	for(int i=1; i<=n; i++){
		for(int j=1; j<=n-i; j++){
			siri(pos[j], 1);
			siri(pos[j+i], 0);
			sort(val.begin(), val.end());
			for(int k=0; k<n; k++){
				q[k]=p[k];
			}
			gazi(pos[j], 1);
			gazi(pos[j+i], 0);
			cout << "query ";
			for(int k=0; k<n; k++){
				cout << q[k] << " ";
			}
			cout << '\n';
			cout.flush();
			cin >> prov;
			if(!prov){
				ms[1][pos[j]].push_back(pos[j+i]);
				ms[0][pos[j+i]].push_back(pos[j]);
			}
		}
	}
	cout << "end\n";
	vector < int > s;
	for(int i=0; i<n; i++){
		s.push_back(i);
	}
	int br;
	set < int >::const_iterator it;
	for(int i=0; i<n; i++){
		br=0;
		for(int j=0; j<ms[0][i].size(); j++){
//			cout << ms[0][i][j] << " ";
			if(ms[0][i][j]>i){
				br++;
			}
		}
//		cout << '\n';
		cout << s[br]+1 << " ";
		s.erase(s.begin()+br);
	}
	cout << '\n';
	for(int i=0; i<n; i++){
		s.push_back(i);
	}
	for(int i=0; i<n; i++){
		br=0;
		for(int j=0; j<ms[1][i].size(); j++){
			if(ms[1][i][j]>i){
				br++;
			}
		}
		cout << s[s.size()-br-1]+1 << " ";
		s.erase(s.end()-1-br);
	}
	cout << '\n';
	cout.flush();
	return 0;
}

Compilation message

zagonetka.cpp: In function 'void siri(int, bool)':
zagonetka.cpp:20:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0; i<ms[s][x].size(); i++){
               ~^~~~~~~~~~~~~~~~
zagonetka.cpp: In function 'void gazi(int, bool)':
zagonetka.cpp:30:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0; i<ms[s][x].size(); i++){
               ~^~~~~~~~~~~~~~~~
zagonetka.cpp: In function 'int main()':
zagonetka.cpp:82:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int j=0; j<ms[0][i].size(); j++){
                ~^~~~~~~~~~~~~~~~
zagonetka.cpp:98:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int j=0; j<ms[1][i].size(); j++){
                ~^~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 17 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 77 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -