Submission #4626

# Submission time Handle Problem Language Result Execution time Memory
4626 2013-11-13T08:00:49 Z cki86201 Parrots (IOI11_parrots) C++
98 / 100
13 ms 2432 KB
#include "encoder.h"
#include "encoderlib.h"

//98point;
void encode(int N, int M[])
{
	int i;
	for(i=0;i<N;i++){
		int b = i<<2;
		int x[4]={0,0,0,0},sum=0;;
		for(int j=0;j<M[i];j++){
			if(sum<7){x[0]++,sum++;continue;}
			if(x[0]){x[0]=0,x[1]++,sum=x[1]+x[2]+x[3];continue;}
			if(x[1]){x[1]=0,x[2]++,sum=x[2]+x[3];continue;}
			if(x[2]){x[2]=0,x[3]++,sum=x[3];continue;}
		}
		for(int j=0;j<4;j++){
			for(int k=0;k<x[j];k++)send(b+j);
		}
	}
}
#include "decoder.h"
#include "decoderlib.h"

void decode(int N, int L, int X[])
{
	int i,op[64];
	int p[64][4];
	for(i=0;i<64;i++)op[i]=p[i][0]=p[i][1]=p[i][2]=p[i][3]=0;
	for(i=0;i<L;i++)p[X[i]>>2][X[i]%4]++;
	for(i=0;i<N;i++){
		int x[4]={p[i][0],p[i][1],p[i][2],p[i][3]};
		int cnt=0;
		while(x[0]|x[1]|x[2]|x[3]){
			cnt++;
			if(x[0]){x[0]--;continue;}
			if(x[1]){x[1]--;x[0]=7-x[3]-x[2]-x[1];continue;}
			if(x[2]){x[2]--;x[1]=7-x[3]-x[2]-x[0];continue;}
			if(x[3]){x[3]--;x[2]=7-x[3]-x[1]-x[0];continue;}
		}
		op[i]=cnt;
	}
	for(i=0;i<N;i++)output(op[i]);
}
# Verdict Execution time Memory Grader output
1 Correct 4 ms 752 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 1592 KB Output is correct
2 Correct 6 ms 1712 KB Output is correct
3 Correct 5 ms 2152 KB Output is correct
4 Correct 5 ms 2152 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 2152 KB Output is correct
2 Correct 5 ms 2152 KB Output is correct
3 Correct 7 ms 2152 KB Output is correct
4 Correct 5 ms 2152 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 2176 KB Output is correct
2 Correct 7 ms 2176 KB Output is correct
3 Correct 6 ms 2184 KB Output is correct
4 Correct 9 ms 2184 KB Output is correct
5 Correct 7 ms 2184 KB Output is correct
6 Correct 9 ms 2184 KB Output is correct
# Verdict Execution time Memory Grader output
1 Partially correct 6 ms 2184 KB Output is partially correct - P = 7.000000
2 Partially correct 9 ms 2184 KB Output is partially correct - P = 7.000000
3 Partially correct 9 ms 2184 KB Output is partially correct - P = 7.000000
4 Partially correct 11 ms 2408 KB Output is partially correct - P = 7.000000
5 Partially correct 13 ms 2408 KB Output is partially correct - P = 7.000000
6 Partially correct 13 ms 2408 KB Output is partially correct - P = 7.000000
7 Partially correct 13 ms 2432 KB Output is partially correct - P = 7.000000