제출 #346509

#제출 시각아이디문제언어결과실행 시간메모리
346509daniel920712앵무새 (IOI11_parrots)C++14
85 / 100
26 ms2128 KiB
#include "encoder.h"
#include "encoderlib.h"
#include <vector>
#include <algorithm>
using namespace std; 

void encode(int N, int M[])
{
	if(N<=32)
	{
		vector < pair < int , int > > all2;
	    int i,t=0;
	    for(i=0; i<N; i++)
	    {
	    	send(M[i]);
	    	send(M[i]);
	    	send(M[i]);
	    	send(M[i]);
	    	all2.push_back(make_pair(M[i],i));
		}
		sort(all2.begin(),all2.end());
		for(i=0;i<N;i++) 
		{
			send(i/8*32+all2[i].second);
			send(i/8*32+all2[i].second);
			send(i%8*32+all2[i].second);
			//printf("%d %d\n",i/8*32,i%8*32);
			
		}
	}
	else 
	{
		vector < pair < int , int > > all2;
	    int i,t=0,j,k;
	    for(i=0; i<N; i++)
	    {
	    	send(M[i]);
	    	send(M[i]);
	    	send(M[i]);
	    	send(M[i]);
	    	
			send(M[i]);
	    	send(M[i]);
	    	send(M[i]);
	    	send(M[i]);
	    	all2.push_back(make_pair(M[i],i));
		}
		sort(all2.begin(),all2.end());
		for(i=0;i<N;i++) 
		{
			t=i;
			for(j=0;j<3;j++)
			{
				for(k=0;k<(1<<(j));k++) 
				{
					if(t%4)
					{
						//printf("%d %d\n",t%4*64+i,i);
						send(t%4*64+all2[i].second);
					}
				} 
				
				t/=4;
			}
			
		}
    
	}
	
}
#include "decoder.h"
#include "decoderlib.h"
#include <map>
#include <vector>
#include <utility>
#include <algorithm>
using namespace std;

void decode(int N, int L, int X[])
{
	if(N<=32)
	{
		 vector < int > all;
	    map < int , int > con;
	    int ans[305];
	    int where[305];
	    int i,j, b;
	    for(i=0; i<L; i++)
	    {
	        con[X[i]]++;
	    }
	 
	    for(auto i:con)
	    {
	        for(j=0;j<i.second/4;j++) all.push_back(i.first);
	    }
	    sort(all.begin(),all.end());
	    for(i=0;i<N;i++) 
		{
			
			//printf("%d\n",all[i]);
			where[i]=0;
		}
	    for(auto i:con)
	    {
	    	//printf("%d %d\n",i.first,i.second);
	    	//if(i.second%4) printf("%d\n",i.first/32);
	        if(i.second%4==2)
	        {
	            //printf("aa %d %d\n",i.first%32,i.first/32);
	            where[i.first%32]+=i.first/32*8;
	        }
	        else if(i.second%4==1)
	        {
	        	//printf("bb %d %d\n",i.first%32,i.first/32);
	        	where[i.first%32]+=i.first/32;
			}
			else if(i.second%4==3)
			{
				//printf("cc %d %d\n",i.first%32,i.first/32);
				where[i.first%32]+=i.first/32;
				where[i.first%32]+=i.first/32*8;
			}
	    }
	    /*for(i=0; i<N; i++)  printf("%d ",where[i]);
		printf("\n"); */
	    for(i=0; i<N; i++) 
		{
			//printf("%d ",where[i]);
			output(all[where[i]]);
			//printf("%d\n",all[where[i]]);
		}
	}
	else 
	{
		vector < int > all;
	    map < int , int > con;
	    int ans[305];
	    int where[305];
	    int i,j, b;
	    for(i=0; i<L; i++)
	    {
	    	//printf("%d ",X[i]);
	        con[X[i]]++;
	    }
	
	    for(auto i:con)
	    {
	        for(j=0;j<i.second/8;j++)
			{
				//printf("%d\n",i.first);
				all.push_back(i.first);
			}
	    }
	    sort(all.begin(),all.end());
	    
	    for(i=0;i<N;i++) 
		{
			where[i]=0;
		}
	
	    for(auto i:con)
	    {
	        for(j=0;j<3;j++)
	        {
	        	if(i.second&(1<<j))
	        	{
	        		where[i.first%64]+=(i.first/64)*(1<<(2*j));
				}
			}
	    }
	    for(i=0; i<N; i++) 
		{
			//printf("%d %d\n",where[i],all[where[i]]);
			output(all[where[i]]);
			
		}
	}
    
}


컴파일 시 표준 에러 (stderr) 메시지

encoder.cpp: In function 'void encode(int, int*)':
encoder.cpp:12:12: warning: unused variable 't' [-Wunused-variable]
   12 |      int i,t=0;
      |            ^

decoder.cpp: In function 'void decode(int, int, int*)':
decoder.cpp:15:10: warning: unused variable 'ans' [-Wunused-variable]
   15 |      int ans[305];
      |          ^~~
decoder.cpp:17:15: warning: unused variable 'b' [-Wunused-variable]
   17 |      int i,j, b;
      |               ^
decoder.cpp:68:10: warning: unused variable 'ans' [-Wunused-variable]
   68 |      int ans[305];
      |          ^~~
decoder.cpp:70:15: warning: unused variable 'b' [-Wunused-variable]
   70 |      int i,j, b;
      |               ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...