제출 #29112

#제출 시각아이디문제언어결과실행 시간메모리
29112aybala앵무새 (IOI11_parrots)C++11
88 / 100
18 ms2576 KiB
#include "encoder.h"
#include "encoderlib.h"
#include<bits/stdc++.h>
#define fori(a,b,c) for(a=b; a<c; a++)
#define ford(a,b,c) for(a=b; a>=c; a--)
#define mp make_pair
#define pb push_back
#define ll long long
#define pii pair<int,int>
using namespace std;

void encode(int N, int M[])
{
	if(N<=32){
		int i;
 
		for(i=0; i<N; i++){
			int x=2;
			int y=0;
			while(M[i]){
				if(M[i]%x){
					send(i*8+y);
					M[i]-=(x/2);
				}
				y++;
				x*=2;
			
			}
			
		}
	}
	else{
		int i;
	
		for(i=0; i<N; i++){
			int x=2;
			int y=0;
			while(M[i]){
				if(M[i]%x){
					if(y%2){
						send(i*4+(y-1)/2);
						send(i*4+(y-1)/2);
					}
					else{
						send((i*4)+(y/2));
					}
					M[i]-=(x/2);
				}
				y++;
				x*=2;
			
			}
			
		}
	}
}

#include "decoder.h"
#include "decoderlib.h"
#include<bits/stdc++.h>
#define fori(a,b,c) for(a=b; a<c; a++)
#define ford(a,b,c) for(a=b; a>=c; a--)
#define mp make_pair
#define pb push_back
#define ll long long
#define pii pair<int,int>
using namespace std;

int us[8]={1,2,4,8,16,32,64,128};

void decode(int N, int L, int X[])
{
	if(N>32){
		sort(X,X+L);
		int i,j,k;
		j=0;
		fori(i,0,N){
			int cod=0;
			while(j<L && X[j]<=i*4+3){
				int xj=X[j];
				int r=0;
				while(j<L && xj==X[j]){
					r++;
					j++;
				}
				xj-=i*4;
				if(r!=2){
					cod+=us[xj*2];
				}
				if(r!=1){
					cod+=us[xj*2+1];
				}
			}
			output(cod);
		}
	}
	else{
		sort(X,X+L);
		int i,j,k;
		j=0;
		fori(i,0,N){
			int cod=0;
			while(j<L && X[j]<=i*8+7){
				X[j]-=i*8;
				cod+=us[X[j]];
				j++;
				
				
			}
			output(cod);
		}

	}
}

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

decoder.cpp: In function 'void decode(int, int, int*)':
decoder.cpp:18:11: warning: unused variable 'k' [-Wunused-variable]
   int i,j,k;
           ^
decoder.cpp:42:11: warning: unused variable 'k' [-Wunused-variable]
   int i,j,k;
           ^
#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...