답안 #67403

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
67403 2018-08-14T08:02:35 Z zetapi 앵무새 (IOI11_parrots) C++14
52 / 100
8 ms 2736 KB
#include "encoder.h"
#include "encoderlib.h"
#include "bits/stdc++.h"
using namespace std;

#define pb  push_back
#define mp  make_pair
#define ll  long long
#define itr ::iterator 

typedef pair<int,int>  pii;

const int MAX=1e5;

void encode(int N,int M[])
{
	int arr[1000];
	vector<pii> vec;
	for(int A=0;A<N;A++)
	{
		send(M[A]);
		send(M[A]);
		send(M[A]);
		vec.pb(mp(M[A],A));
	}	
	sort(vec.begin(),vec.end());
	for(int A=0;A<vec.size();A++)
		arr[vec[A].second]=A;
	set<int> st;
 	for(int A=0;A<N;A++)
	{
		int res=A;
		for(int B=0;B<4;B++)
		{
			if(arr[A]&(1<<B))
				res+=1<<(B+4);
		}	
		assert(st.find(res)==st.end());
		st.insert(res);
		send(res);
	}
	return ;
}
#include "decoder.h"
#include "decoderlib.h"
#include "bits/stdc++.h"
using namespace std;

#define pb  push_back
#define mp  make_pair
#define ll  long long
#define itr ::iterator 

typedef pair<int,int>  pii;

const int MAX=1e5;

void decode(int N, int L, int X[])
{
    assert(L==4*N);
	vector<int> vec;
	map<int,int> maps;
	int res[1000]={0};
  	for(int A=0;A<L;A++)
  		maps[X[A]]++;
  	for(auto A:maps)
  	{
  		int cur=A.second;
  		while(cur>=3)
  		{
  			cur-=3;
  			vec.pb(A.first);
  		}
  	}
  	sort(vec.begin(),vec.end());
  	for(auto A:maps)
  	{
  		if(A.second%3==0)
  			continue;
  		int ind=0,num=0;
  		for(int B=0;B<4;B++)
  			if(A.first&(1<<B))
  				ind+=(1<<B);
  		for(int B=0;B<4;B++)
  			if(A.first&(1<<(B+4)))
  				num+=(1<<B);
  		assert(res[ind]==0);
  		res[ind]=num;
  	}
  	for(int A=0;A<N;A++)
  		output(vec[res[A]]);
  	return ;
}

Compilation message

encoder.cpp: In function 'void encode(int, int*)':
encoder.cpp:27:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int A=0;A<vec.size();A++)
              ~^~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 752 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 1704 KB Output is correct
2 Correct 7 ms 1960 KB Output is correct
3 Correct 7 ms 2024 KB Output is correct
4 Correct 7 ms 2056 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 2056 KB Output is correct
2 Correct 7 ms 2200 KB Output is correct
3 Correct 8 ms 2264 KB Output is correct
4 Correct 8 ms 2264 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 2264 KB Output is correct
2 Correct 8 ms 2264 KB Output is correct
3 Runtime error 4 ms 1132 KB Execution killed with signal 11 (could be triggered by violating memory limits)
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 2736 KB Output is correct - P = 4.000000
2 Incorrect 5 ms 2736 KB Error : Bad encoded integer
3 Incorrect 4 ms 2736 KB Error : Bad encoded integer
4 Incorrect 6 ms 2736 KB Error : Bad encoded integer
5 Incorrect 5 ms 2736 KB Error : Bad encoded integer
6 Incorrect 4 ms 2736 KB Error : Bad encoded integer
7 Incorrect 5 ms 2736 KB Error : Bad encoded integer