Submission #351938

#TimeUsernameProblemLanguageResultExecution timeMemory
351938juggernautParrots (IOI11_parrots)C++14
Compilation error
0 ms0 KiB
#include"encoder.h" #include"encoderlib.h" #include<bits/stdc++.h> using namespace std; int counter[256]; void encode(int n,int a[]){ vector<int>best(n*15,0); int sig; for(int xr=0;xr<256;xr++){ vector<int>vec; for(int i=0;i<n;i++){ int x=a[i]^xr; while(x>63)vec.push_back((i<<2)|3),x-=64; while(x>15)vec.push_back((i<<2)|2),x-=16; while(x>3)vec.push_back((i<<2)|1),x-=4; while(x>0)vec.push_back((i<<2)|0),x-=1; } if(vec.size()<best.size())best=vec,sig=xr; } int mx=0; for(auto to:best){ counter[to]++; mx=max(mx,counter[to]); send(to); } if(counter[sig])exit(-1); for(int i=0;i<=mx;i++)send(sig); }
#include "encoder.h" #include "decoder.h" #include "encoderlib.h" #include "decoderlib.h" #include <stdio.h> #include <stdlib.h> #define MAX_N 1000 #define MAX_L 10000 #define CHANNEL_RANGE 65535 #define MAX_EXPANSION 10 static int message[MAX_N]; static int N; // NN; static int encoded_message[MAX_L]; static int L; static int output_message[MAX_N]; static int O; inline void my_assert(int e){ if (!e) abort(); }; void send(int a) { if(L == MAX_L) { printf("Encoded message too long.\n"); exit(0); } encoded_message[L] = a; L++; } void output(int b) { if(O == N) O++; if(O > N) return; output_message[O] = b; O++; } static void shuffle() { int t,i; i=0; while(i < L-1) { t = encoded_message[i]; encoded_message[i] = encoded_message[i+1]; encoded_message[i+1] = t; i += 2; } } static void check_encoded_message() { int i; if(L > MAX_EXPANSION * N) { printf("Encoded message too long."); exit(0); } for(i=0; i < L; i++) if((encoded_message[i] < 0) || (encoded_message[i] > CHANNEL_RANGE)) { printf("Bad encoded integer.\n"); exit(0); } } static int check_output() { int i; if(O!=N) return 0; for(i = 0; i < N; i++) if(message[i] != output_message[i]) return 0; return 1; } int main() { int i,t; double ratio; my_assert(1==scanf("%d",&N)); for(i = 0; i < N; i++) my_assert(1==scanf("%d",&message[i])); ratio = 0; for(t=0; t<2; t++) { L = 0; encode(N,message); check_encoded_message(); if((double) L / N > ratio) ratio = ((double)L)/N; if(t==1) shuffle(); // NN = 0; O = 0; decode(N,L,encoded_message); if(!check_output()) { printf("Incorrect.\n"); exit(0); } } printf("Correct.\n"); fprintf(stderr,"Ratio = %3.3f\n",ratio); return 0; }

Compilation message (stderr)

encoder.cpp: In function 'void encode(int, int*)':
encoder.cpp:27:31: warning: 'sig' may be used uninitialized in this function [-Wmaybe-uninitialized]
   27 |     for(int i=0;i<=mx;i++)send(sig);
      |                           ~~~~^~~~~

/tmp/ccazaSLS.o: In function `output(int)':
decoder.cpp:(.text+0x50): multiple definition of `output(int)'
/tmp/ccCQqO59.o:grader_decoder.cpp:(.text+0x40): first defined here
/tmp/ccazaSLS.o: In function `main':
decoder.cpp:(.text.startup+0x0): multiple definition of `main'
/tmp/ccCQqO59.o:grader_decoder.cpp:(.text.startup+0x0): first defined here
/tmp/ccazaSLS.o: In function `main':
decoder.cpp:(.text.startup+0x93): undefined reference to `encode(int, int*)'
decoder.cpp:(.text.startup+0x12e): undefined reference to `decode(int, int, int*)'
/tmp/ccCQqO59.o: In function `main':
grader_decoder.cpp:(.text.startup+0x21f): undefined reference to `decode(int, int, int*)'
collect2: error: ld returned 1 exit status