#include "grader.h"
#include "encoder.h"
#include <bits/stdc++.h>
using namespace std;
// macros
typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef pair<ll, ll> lll;
typedef tuple<int, int, int> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<ll> vll;
typedef vector<lll> vlll;
#define REP(a,b,c) for(int a=int(b); a<int(c); a++)
#define RE(a,c) REP(a,0,c)
#define RE1(a,c) REP(a,1,c+1)
#define REI(a,b,c) REP(a,b,c+1)
#define REV(a,b,c) for(int a=int(c-1); a>=int(b); a--)
#define FOR(a,b) for(auto& a : b)
#define all(a) a.begin(), a.end()
#define INF 1e9
#define EPS 1e-9
#define pb push_back
#define popb pop_back
#define fi first
#define se second
void writeSmallInt(int x, int bits) {
RE(i,bits) {
bool b = false;
if(x & (1<<i)) b = 1;
encode_bit(b);
}
}
int maxBits(int x) {
int mx = 0;
RE(i,10) if(x&(1<<i)) mx = max(mx, i+1);
return mx;
}
void encode(int nv, int nh, int ne, int *v1, int *v2) {
vector<vi> adj; adj.resize(nv);
set<ii> difEdges;
RE(i,ne) {
adj[v1[i]].pb(v2[i]);
adj[v2[i]].pb(v1[i]);
difEdges.insert({v1[i],v2[i]});
difEdges.insert({v2[i],v1[i]});
}
set<ii> usedEdges;
RE(h,nh) {
// bfs
vi dist; dist.assign(nv, -1);
queue<int> q;
q.push(h); dist[h] = 0;
while(!q.empty()) {
int u = q.front(); q.pop();
FOR(v,adj[u]) {
if(dist[v] != -1) continue;
dist[v] = dist[u] + 1;
q.push(v);
}
}
vi prev = {h};
RE1(i,nv) {
vi cur;
RE(u,nv) if(dist[u] == i) cur.pb(u);
FOR(u,cur) {
bool found = false;
FOR(v,prev) if(usedEdges.count({min(u,v),max(u,v)})) {
found = true;
break;
}
if(!found) FOR(v,prev) if(difEdges.count({u,v})) {
usedEdges.insert({min(u,v),max(u,v)});
break;
}
}
if(cur.empty()) break;
prev = cur;
}
}
RE(i,nv) adj[i].clear();
FOR(p,usedEdges) adj[p.se].pb(p.fi);
RE(i,nv) {
writeSmallInt(adj[i].size(), 10);
FOR(v,adj[i]) writeSmallInt(v, 10);
}
}
#include "grader.h"
#include "decoder.h"
#include <bits/stdc++.h>
using namespace std;
// macros
typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef pair<ll, ll> lll;
typedef tuple<int, int, int> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<ll> vll;
typedef vector<lll> vlll;
#define REP(a,b,c) for(int a=int(b); a<int(c); a++)
#define RE(a,c) REP(a,0,c)
#define RE1(a,c) REP(a,1,c+1)
#define REI(a,b,c) REP(a,b,c+1)
#define REV(a,b,c) for(int a=int(c-1); a>=int(b); a--)
#define FOR(a,b) for(auto& a : b)
#define all(a) a.begin(), a.end()
#define INF 1e9
#define EPS 1e-9
#define pb push_back
#define popb pop_back
#define fi first
#define se second
int readSmallInt(int bits) {
int res = 0;
RE(i,bits) {
bool b = decode_bit();
if(b) res |= (1<<i);
}
return res;
}
int maxBits(int x) {
int mx = 0;
RE(i,10) if(x&(1<<i)) mx = max(mx, i+1);
return mx;
}
void decode(int nv, int nh) {
// reconstruct graph
vector<vi> adj; adj.resize(nv);
RE(u,nv) {
int sz = readSmallInt(10);
RE(j,sz) {
int v = readSmallInt(10);
adj[u].pb(v);
adj[v].pb(u);
}
}
RE(h,nh) {
// bfs
vi dist; dist.assign(nv, -1);
queue<int> q;
q.push(h); dist[h] = 0;
while(!q.empty()) {
int u = q.front(); q.pop();
hops(h,u,dist[u]);
FOR(v,adj[u]) {
if(dist[v] != -1) continue;
dist[v] = dist[u] + 1;
q.push(v);
}
}
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
622 ms |
35616 KB |
Output is partially correct - 187300 call(s) of encode_bit() |
2 |
Correct |
3 ms |
4592 KB |
Output is correct - 120 call(s) of encode_bit() |
3 |
Correct |
141 ms |
5644 KB |
Output is correct - 43600 call(s) of encode_bit() |
4 |
Correct |
3 ms |
4592 KB |
Output is correct - 140 call(s) of encode_bit() |
5 |
Correct |
146 ms |
6948 KB |
Output is partially correct - 85990 call(s) of encode_bit() |
6 |
Correct |
181 ms |
6932 KB |
Output is partially correct - 87960 call(s) of encode_bit() |
7 |
Correct |
191 ms |
10012 KB |
Output is partially correct - 158660 call(s) of encode_bit() |
8 |
Correct |
51 ms |
5188 KB |
Output is correct - 26590 call(s) of encode_bit() |
9 |
Correct |
54 ms |
5384 KB |
Output is correct - 25670 call(s) of encode_bit() |
10 |
Correct |
52 ms |
5272 KB |
Output is correct - 25350 call(s) of encode_bit() |
11 |
Correct |
80 ms |
6332 KB |
Output is correct - 40970 call(s) of encode_bit() |
12 |
Correct |
108 ms |
5004 KB |
Output is correct - 19990 call(s) of encode_bit() |
13 |
Correct |
166 ms |
10124 KB |
Output is partially correct - 93520 call(s) of encode_bit() |
14 |
Correct |
98 ms |
5576 KB |
Output is correct - 29890 call(s) of encode_bit() |
15 |
Correct |
91 ms |
5844 KB |
Output is correct - 31980 call(s) of encode_bit() |
16 |
Correct |
152 ms |
9220 KB |
Output is correct - 55200 call(s) of encode_bit() |
17 |
Correct |
134 ms |
8544 KB |
Output is correct - 50890 call(s) of encode_bit() |
18 |
Correct |
157 ms |
9920 KB |
Output is correct - 66880 call(s) of encode_bit() |
19 |
Correct |
123 ms |
7816 KB |
Output is partially correct - 70860 call(s) of encode_bit() |
20 |
Correct |
179 ms |
11512 KB |
Output is partially correct - 77510 call(s) of encode_bit() |
21 |
Correct |
228 ms |
12636 KB |
Output is partially correct - 81980 call(s) of encode_bit() |
22 |
Correct |
189 ms |
10332 KB |
Output is partially correct - 130590 call(s) of encode_bit() |
23 |
Correct |
234 ms |
13888 KB |
Output is partially correct - 112230 call(s) of encode_bit() |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
622 ms |
35616 KB |
Output is partially correct - 187300 call(s) of encode_bit() |
2 |
Correct |
3 ms |
4592 KB |
Output is correct - 120 call(s) of encode_bit() |
3 |
Correct |
141 ms |
5644 KB |
Output is correct - 43600 call(s) of encode_bit() |
4 |
Correct |
3 ms |
4592 KB |
Output is correct - 140 call(s) of encode_bit() |
5 |
Correct |
146 ms |
6948 KB |
Output is partially correct - 85990 call(s) of encode_bit() |
6 |
Correct |
181 ms |
6932 KB |
Output is partially correct - 87960 call(s) of encode_bit() |
7 |
Correct |
191 ms |
10012 KB |
Output is partially correct - 158660 call(s) of encode_bit() |
8 |
Correct |
51 ms |
5188 KB |
Output is correct - 26590 call(s) of encode_bit() |
9 |
Correct |
54 ms |
5384 KB |
Output is correct - 25670 call(s) of encode_bit() |
10 |
Correct |
52 ms |
5272 KB |
Output is correct - 25350 call(s) of encode_bit() |
11 |
Correct |
80 ms |
6332 KB |
Output is correct - 40970 call(s) of encode_bit() |
12 |
Correct |
108 ms |
5004 KB |
Output is correct - 19990 call(s) of encode_bit() |
13 |
Correct |
166 ms |
10124 KB |
Output is partially correct - 93520 call(s) of encode_bit() |
14 |
Correct |
98 ms |
5576 KB |
Output is correct - 29890 call(s) of encode_bit() |
15 |
Correct |
91 ms |
5844 KB |
Output is correct - 31980 call(s) of encode_bit() |
16 |
Correct |
152 ms |
9220 KB |
Output is correct - 55200 call(s) of encode_bit() |
17 |
Correct |
134 ms |
8544 KB |
Output is correct - 50890 call(s) of encode_bit() |
18 |
Correct |
157 ms |
9920 KB |
Output is correct - 66880 call(s) of encode_bit() |
19 |
Correct |
123 ms |
7816 KB |
Output is partially correct - 70860 call(s) of encode_bit() |
20 |
Correct |
179 ms |
11512 KB |
Output is partially correct - 77510 call(s) of encode_bit() |
21 |
Correct |
228 ms |
12636 KB |
Output is partially correct - 81980 call(s) of encode_bit() |
22 |
Correct |
189 ms |
10332 KB |
Output is partially correct - 130590 call(s) of encode_bit() |
23 |
Correct |
234 ms |
13888 KB |
Output is partially correct - 112230 call(s) of encode_bit() |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
622 ms |
35616 KB |
Output is partially correct - 187300 call(s) of encode_bit() |
2 |
Correct |
3 ms |
4592 KB |
Output is correct - 120 call(s) of encode_bit() |
3 |
Correct |
141 ms |
5644 KB |
Output is correct - 43600 call(s) of encode_bit() |
4 |
Correct |
3 ms |
4592 KB |
Output is correct - 140 call(s) of encode_bit() |
5 |
Correct |
146 ms |
6948 KB |
Output is partially correct - 85990 call(s) of encode_bit() |
6 |
Correct |
181 ms |
6932 KB |
Output is partially correct - 87960 call(s) of encode_bit() |
7 |
Correct |
191 ms |
10012 KB |
Output is partially correct - 158660 call(s) of encode_bit() |
8 |
Correct |
51 ms |
5188 KB |
Output is correct - 26590 call(s) of encode_bit() |
9 |
Correct |
54 ms |
5384 KB |
Output is correct - 25670 call(s) of encode_bit() |
10 |
Correct |
52 ms |
5272 KB |
Output is correct - 25350 call(s) of encode_bit() |
11 |
Correct |
80 ms |
6332 KB |
Output is correct - 40970 call(s) of encode_bit() |
12 |
Correct |
108 ms |
5004 KB |
Output is correct - 19990 call(s) of encode_bit() |
13 |
Correct |
166 ms |
10124 KB |
Output is partially correct - 93520 call(s) of encode_bit() |
14 |
Correct |
98 ms |
5576 KB |
Output is correct - 29890 call(s) of encode_bit() |
15 |
Correct |
91 ms |
5844 KB |
Output is correct - 31980 call(s) of encode_bit() |
16 |
Correct |
152 ms |
9220 KB |
Output is correct - 55200 call(s) of encode_bit() |
17 |
Correct |
134 ms |
8544 KB |
Output is correct - 50890 call(s) of encode_bit() |
18 |
Correct |
157 ms |
9920 KB |
Output is correct - 66880 call(s) of encode_bit() |
19 |
Correct |
123 ms |
7816 KB |
Output is partially correct - 70860 call(s) of encode_bit() |
20 |
Correct |
179 ms |
11512 KB |
Output is partially correct - 77510 call(s) of encode_bit() |
21 |
Correct |
228 ms |
12636 KB |
Output is partially correct - 81980 call(s) of encode_bit() |
22 |
Correct |
189 ms |
10332 KB |
Output is partially correct - 130590 call(s) of encode_bit() |
23 |
Correct |
234 ms |
13888 KB |
Output is partially correct - 112230 call(s) of encode_bit() |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
622 ms |
35616 KB |
Output is partially correct - 187300 call(s) of encode_bit() |
2 |
Correct |
3 ms |
4592 KB |
Output is correct - 120 call(s) of encode_bit() |
3 |
Correct |
141 ms |
5644 KB |
Output is correct - 43600 call(s) of encode_bit() |
4 |
Correct |
3 ms |
4592 KB |
Output is correct - 140 call(s) of encode_bit() |
5 |
Correct |
146 ms |
6948 KB |
Output is partially correct - 85990 call(s) of encode_bit() |
6 |
Correct |
181 ms |
6932 KB |
Output is partially correct - 87960 call(s) of encode_bit() |
7 |
Correct |
191 ms |
10012 KB |
Output is partially correct - 158660 call(s) of encode_bit() |
8 |
Correct |
51 ms |
5188 KB |
Output is correct - 26590 call(s) of encode_bit() |
9 |
Correct |
54 ms |
5384 KB |
Output is correct - 25670 call(s) of encode_bit() |
10 |
Correct |
52 ms |
5272 KB |
Output is correct - 25350 call(s) of encode_bit() |
11 |
Correct |
80 ms |
6332 KB |
Output is correct - 40970 call(s) of encode_bit() |
12 |
Correct |
108 ms |
5004 KB |
Output is correct - 19990 call(s) of encode_bit() |
13 |
Correct |
166 ms |
10124 KB |
Output is partially correct - 93520 call(s) of encode_bit() |
14 |
Correct |
98 ms |
5576 KB |
Output is correct - 29890 call(s) of encode_bit() |
15 |
Correct |
91 ms |
5844 KB |
Output is correct - 31980 call(s) of encode_bit() |
16 |
Correct |
152 ms |
9220 KB |
Output is correct - 55200 call(s) of encode_bit() |
17 |
Correct |
134 ms |
8544 KB |
Output is correct - 50890 call(s) of encode_bit() |
18 |
Correct |
157 ms |
9920 KB |
Output is correct - 66880 call(s) of encode_bit() |
19 |
Correct |
123 ms |
7816 KB |
Output is partially correct - 70860 call(s) of encode_bit() |
20 |
Correct |
179 ms |
11512 KB |
Output is partially correct - 77510 call(s) of encode_bit() |
21 |
Correct |
228 ms |
12636 KB |
Output is partially correct - 81980 call(s) of encode_bit() |
22 |
Correct |
189 ms |
10332 KB |
Output is partially correct - 130590 call(s) of encode_bit() |
23 |
Correct |
234 ms |
13888 KB |
Output is partially correct - 112230 call(s) of encode_bit() |