# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
295705 |
2020-09-09T20:25:35 Z |
b00n0rp |
Parrots (IOI11_parrots) |
C++17 |
|
12 ms |
1792 KB |
#include "encoder.h"
#include "encoderlib.h"
#include<bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i = 0; i < n; i ++)
#define FOR(i,a,b) for(int i = a; i < b; i ++)
#define vi vector<int>
#define pb push_back
#define F first
#define S second
void encode(int N, int M[]){
int n = N;
int a[105];
REP(i,n) a[i] = M[i];
vi v1,v2;
REP(i,n){
int times = 1;
if(i >= 32) times++;
int cur = (i%32)*8;
REP(j,8){
if(a[i]&(1<<j)){
REP(k,times){
v1.pb(cur+j);
}
}
else{
REP(k,times){
v2.pb(cur+j);
}
}
}
}
if(v1.size() <= 6*n){
for(auto x:v1) send(x);
}
else{
map<int,int> m;
for(auto x:v2) m[x]++;
bool f = 0;
for(auto x:m){
if(x.S >= 3){
m[x.F] += 1;
f = 1;
break;
}
}
if(!f){
send(0);
send(0);
send(0);
send(0);
send(0);
}
for(auto x:m){
REP(y,x.S) send(x.F);
}
}
}
#include "decoder.h"
#include "decoderlib.h"
#include<bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i = 0; i < n; i ++)
#define FOR(i,a,b) for(int i = a; i < b; i ++)
#define F first
#define S second
void decode(int N, int L, int X[]){
int ans[105];
REP(i,N) ans[i] = 0;
map<int,int> m;
REP(i,L) m[X[i]]++;
bool flag = 0;
for(auto x:m){
if(x.S >= 4){
flag = 1;
m[x.F] -= 1;
if(m[x.F] >= 4) m[x.F] -= 4;
break;
}
}
for(auto x:m){
int ind = x.F/8;
if(x.S&2) ans[ind+32] += (1<<(x.F%8));
if(x.S&1) ans[ind] += (1<<(x.F%8));
}
if(!flag){
REP(i,N) output(ans[i]);
}
else{
REP(i,N) output(255-ans[i]);
}
}
Compilation message
encoder.cpp: In function 'void encode(int, int*)':
encoder.cpp:38:15: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
38 | if(v1.size() <= 6*n){
| ~~~~~~~~~~^~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
900 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
1536 KB |
Output is correct |
2 |
Correct |
2 ms |
1536 KB |
Output is correct |
3 |
Correct |
2 ms |
1536 KB |
Output is correct |
4 |
Correct |
4 ms |
1536 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
1536 KB |
Output is correct |
2 |
Correct |
2 ms |
1536 KB |
Output is correct |
3 |
Correct |
3 ms |
1536 KB |
Output is correct |
4 |
Correct |
3 ms |
1536 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
1536 KB |
Output is correct |
2 |
Correct |
3 ms |
1536 KB |
Output is correct |
3 |
Correct |
4 ms |
1792 KB |
Output is correct |
4 |
Correct |
6 ms |
1536 KB |
Output is correct |
5 |
Correct |
4 ms |
1536 KB |
Output is correct |
6 |
Correct |
4 ms |
1536 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
1536 KB |
Output is correct - P = 4.625000 |
2 |
Correct |
5 ms |
1536 KB |
Output is correct - P = 4.718750 |
3 |
Correct |
4 ms |
1536 KB |
Output is correct - P = 5.000000 |
4 |
Partially correct |
8 ms |
1792 KB |
Output is partially correct - P = 5.860000 |
5 |
Partially correct |
11 ms |
1792 KB |
Output is partially correct - P = 6.000000 |
6 |
Partially correct |
11 ms |
1792 KB |
Output is partially correct - P = 6.000000 |
7 |
Partially correct |
12 ms |
1792 KB |
Output is partially correct - P = 6.000000 |