Submission #231059

#TimeUsernameProblemLanguageResultExecution timeMemory
231059Dilshod_ImomovParrots (IOI11_parrots)C++17
98 / 100
26 ms1792 KiB
#include "encoder.h" #include "encoderlib.h" #include <bits/stdc++.h> using namespace std; const int MAXN = 300; int cnt_a[MAXN], cnt_b[MAXN], cnt_c[MAXN], cnt_d[MAXN]; void encode(int N, int M[]) { int x = 0; for ( int a = 0; a < 7; a++ ) { for ( int b = 0; b < 7; b++ ) { for ( int c = 0; c < 7; c++ ) { for ( int d = 0; d < 7; d++ ) { if ( x == 256 ) { break; } if ( a + b + c + d < 8 && a + b + c + d > 0 ) { cnt_a[x] = a; cnt_b[x] = b; cnt_c[x] = c; cnt_d[x] = d; x++; } } if ( x == 256 ) { break; } } if ( x == 256 ) { break; } } if ( x == 256 ) { break; } } x = 0; map < pair < int, int > , int > mp; for ( int i = 0; i < N; i++ ) { for ( int j = 0; j < 4; j++ ) { mp[ { i, j } ] = x++; } } for ( int i = 0; i < N; i++ ) { int z = M[i]; for ( int j = 0; j < cnt_a[z]; j++ ) { send( mp[ { i, 0 } ] ); } for ( int j = 0; j < cnt_b[z]; j++ ) { send( mp[ { i, 1 } ] ); } for ( int j = 0; j < cnt_c[z]; j++ ) { send( mp[ { i, 2 } ] ); } for ( int j = 0; j < cnt_d[z]; j++ ) { send( mp[ { i, 3 } ] ); } } }
#include "decoder.h" #include "decoderlib.h" #include <bits/stdc++.h> using namespace std; void decode(int N, int L, int X[]) { string aa, bb, cc, dd; int x = 0; map < string, int > mp; for ( int a = 0; a < 7; a++ ) { if ( a ) { aa += '0'; } bb = ""; for ( int b = 0; b < 7; b++ ) { if ( b ) { bb += '1'; } cc = ""; for ( int c = 0; c < 7; c++ ) { if ( c ) { cc += '2'; } dd = ""; for ( int d = 0; d < 7; d++ ) { if ( x == 256 ) { break; } if ( d ) { dd += '3'; } if ( a + b + c + d < 8 && a + b + c + d > 0 ) { string s = aa + bb + cc + dd; mp[s] = x++; } } if ( x == 256 ) { break; } } if ( x == 256 ) { break; } } if ( x == 256 ) { break; } } map < int, pair < int, int > > mp1; x = 0; for ( int i = 0; i < N; i++ ) { for ( int j = 0; j < 4; j++ ) { mp1[ x++ ] = { i, j }; } } vector < int > vc[65]; for ( int i = 0; i < L; i++ ) { auto pr = mp1[X[i]]; vc[ pr.first ].push_back( pr.second ); } for ( int i = 0; i < N; i++ ) { int a = 0, b = 0, c = 0, d = 0; for ( auto j: vc[i] ) { if ( j == 0 ) { a++; } else if ( j == 1 ) { b++; } else if ( j == 2 ) { c++; } else { d++; } } string s; for ( int j = 0; j < a; j++ ) { s += '0'; } for ( int j = 0; j < b; j++ ) { s += '1'; } for ( int j = 0; j < c; j++ ) { s += '2'; } for ( int j = 0; j < d; j++ ) { s += '3'; } output(mp[s]); } }
#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...