답안 #463839

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
463839 2021-08-11T21:54:29 Z mosiashvililuka Secret Permutation (RMI19_permutation) C++14
53.1429 / 100
54 ms 332 KB
#include<bits/stdc++.h>
#include "permutationc.h"
using namespace std;
int a,b,c,d,e,i,j,ii,jj,zx,xc,p[1009],pi,ONE,LAST,A[4][1009],mn,f[1009];
vector <int> v,vv,ans;
void solve(int N);
int query(std::vector<int> V);
void answer(std::vector<int> P);
void Fill(vector <int>& q){
	int FX[280];
	for(int h=0; h<=a+1; h++){
		FX[h]=0;
	}
	for(int h=0; h<q.size(); h++){
		FX[q[h]]=1;
	}
	for(int h=1; h<=a; h++){
		if(FX[h]==0){
			q.push_back(h);
		}
	}
}
int diff(int Q, int q, int w){
	vector <int> qw;
	qw.clear();qw.push_back(q);qw.push_back(w);qw.push_back(Q);//A[i-1]-A[1]
	Fill(qw);
	int as=query(qw);
	qw.clear();qw.push_back(w);qw.push_back(q);qw.push_back(Q);//A[i]-A[1]
	Fill(qw);
	int sd=query(qw);
	return sd-as;
}
void solve(int N){
	a=N;
	A[1][2]=0;
	for(i=3; i<=a; i++){
		A[1][i]=A[1][i-1]+diff(1,i,i-1);
	}
	A[2][3]=A[1][2]+diff(2,3,1);
	for(i=4; i<=a; i++){
		A[2][i]=A[2][i-1]+diff(2,i,i-1);
	}
	mn=0;c=1;d=2;
	for(i=3; i<=a; i++){
		if(mn>A[1][i]){
			mn=A[1][i];c=1;d=i;
		}
		if(mn>A[2][i]){
			mn=A[2][i];c=2;d=i;
		}
	}
	//-mn
	mn--;
	for(i=2; i<=a; i++){
		if(i!=2) A[2][i]-=mn;
		A[1][i]-=mn;
	}
	
	
	/*cout<<"  ";for(i=2; i<=a; i++){
		cout<<A[1][i]<<" ";
	}
	cout<<endl;
	cout<<"  "<<"  ";for(i=3; i<=a; i++){
		cout<<A[2][i]<<" ";
	}
	cout<<endl;*/
	f[1]=0;f[2]=A[1][2];
	for(i=3; i<=a; i++){
		if(/*A[1][i]==A[2][i]+A[1][2]*/abs(A[1][i]-A[1][2])==A[2][i]){
			f[i]=f[1]+A[1][i];
		}else{
			f[i]=f[1]-A[1][i];
		}
	}
	mn=0;
	for(i=1; i<=a; i++){
		if(mn>f[i]){
			mn=f[i];
		}
	}
	mn--;
	for(i=1; i<=a; i++) f[i]-=mn;
	ans.clear();
	for(i=1; i<=a; i++){
		ans.push_back(f[i]);
	}
	answer(ans);
}




//
/*int FA[1009];
int query(vector <int> V){
	int qw=0;
	for(int h=1; h<V.size(); h++){
		qw+=abs(FA[V[h]]-FA[V[h-1]]);
	}
	return qw;
}
void answer(vector <int> P){
	for(int h=0; h<P.size(); h++){
		cout<<P[h]<<" ";
	}
	exit(0);
}
int main(){
	ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
	cin>>a;
	for(i=1; i<=a; i++){
		cin>>c;
		FA[i]=c;
	}
	solve(a);
	return 0;
}*/

Compilation message

permutation.cpp: In function 'void Fill(std::vector<int>&)':
permutation.cpp:14:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   14 |  for(int h=0; h<q.size(); h++){
      |               ~^~~~~~~~~
stub.cpp: In function 'int query(int*)':
stub.cpp:15:9: warning: ignoring return value of 'int fscanf(FILE*, const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |   fscanf(stdin, "%d", &x);
      |   ~~~~~~^~~~~~~~~~~~~~~~~
stub.cpp: In function 'int main(int, char**)':
stub.cpp:48:9: warning: ignoring return value of 'int fscanf(FILE*, const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   48 |   fscanf(stdin, "%d", &N);
      |   ~~~~~~^~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Partially correct 1 ms 200 KB Partially correct
2 Partially correct 1 ms 300 KB Partially correct
3 Partially correct 1 ms 200 KB Partially correct
4 Partially correct 0 ms 296 KB Partially correct
5 Partially correct 1 ms 200 KB Partially correct
6 Partially correct 0 ms 300 KB Partially correct
# 결과 실행 시간 메모리 Grader output
1 Partially correct 1 ms 200 KB Partially correct
2 Partially correct 1 ms 300 KB Partially correct
3 Partially correct 1 ms 200 KB Partially correct
4 Partially correct 0 ms 296 KB Partially correct
5 Partially correct 1 ms 200 KB Partially correct
6 Partially correct 0 ms 300 KB Partially correct
7 Partially correct 5 ms 304 KB Partially correct
8 Partially correct 4 ms 200 KB Partially correct
9 Partially correct 4 ms 304 KB Partially correct
10 Partially correct 5 ms 200 KB Partially correct
11 Partially correct 4 ms 200 KB Partially correct
12 Partially correct 4 ms 332 KB Partially correct
13 Partially correct 5 ms 300 KB Partially correct
14 Partially correct 4 ms 308 KB Partially correct
15 Partially correct 4 ms 324 KB Partially correct
16 Partially correct 4 ms 296 KB Partially correct
# 결과 실행 시간 메모리 Grader output
1 Partially correct 1 ms 200 KB Partially correct
2 Partially correct 1 ms 300 KB Partially correct
3 Partially correct 1 ms 200 KB Partially correct
4 Partially correct 0 ms 296 KB Partially correct
5 Partially correct 1 ms 200 KB Partially correct
6 Partially correct 0 ms 300 KB Partially correct
7 Partially correct 5 ms 304 KB Partially correct
8 Partially correct 4 ms 200 KB Partially correct
9 Partially correct 4 ms 304 KB Partially correct
10 Partially correct 5 ms 200 KB Partially correct
11 Partially correct 4 ms 200 KB Partially correct
12 Partially correct 4 ms 332 KB Partially correct
13 Partially correct 5 ms 300 KB Partially correct
14 Partially correct 4 ms 308 KB Partially correct
15 Partially correct 4 ms 324 KB Partially correct
16 Partially correct 4 ms 296 KB Partially correct
17 Partially correct 43 ms 308 KB Partially correct
18 Partially correct 41 ms 280 KB Partially correct
19 Partially correct 41 ms 284 KB Partially correct
20 Partially correct 47 ms 288 KB Partially correct
21 Partially correct 40 ms 292 KB Partially correct
22 Partially correct 36 ms 288 KB Partially correct
23 Partially correct 45 ms 284 KB Partially correct
24 Partially correct 54 ms 288 KB Partially correct
25 Partially correct 41 ms 288 KB Partially correct
26 Partially correct 39 ms 288 KB Partially correct