#include<bits/stdc++.h>
#include "grader.h"
#include "encoder.h"
using namespace std;
vector<int> adj[1005];
bool vis[1005];
int dis[1005];
void binary (int n) {
for (int i = 0; i < 10; i++)
if ((1 << i) & n) encode_bit(1);
else encode_bit(0);
}
bool COOL[1001][1001];
void encode(int nv, int nh, int ne, int *v1, int *v2){
for (int i = 0; i < ne; i++) {
adj[v1[i]].push_back(v2[i]);
adj[v2[i]].push_back(v1[i]);
}
for (int s = 0; s < nh; s++) {
queue<int> q;
q.push(s);
vis[s] = 1;
while (!q.empty()) {
int v = q.front();
q.pop();
for (auto i : adj[v]) {
if (!vis[i]) {
vis[i] = 1;
dis[i] = dis[v] + 1;
q.push(i);
COOL[i][v] = COOL[v][i] = 1;
}
}
}
memset(vis,0,sizeof vis);
memset(dis,0,sizeof dis);
}
int ans = 0;
vector<pair<int,int> > v;
for (int i = 0; i < nv; i++)
for (int j = i; j < nv; j++)
if (COOL[i][j]) {
ans++;
v.push_back({i,j});
}
sort(v.begin(),v.end());
int cur = 0;
for (auto i : v) {
while (cur != i.first) {
binary(1023);
cur++;
}
binary(i.second);
}
binary(1022);
}
#include<bits/stdc++.h>
#include "grader.h"
#include "decoder.h"
using namespace std;
vector<int> adj[1005];
bool vis[1005];
int dis[1005];
void decode(int nv, int nh) {
int cur = 0;
while (cur <= nv) {
int s = 0;
for (int i = 0; i < 10; i++)
if (decode_bit())
s |= (1 << i);
if (s == 1022) break;
if (s == 1023) cur++;
else {
adj[cur].push_back(s);
adj[s].push_back(cur);
}
}
for (int s = 0; s < nh; s++) {
hops(s,s,0);
queue<int> q;
q.push(s);
vis[s] = 1;
while (!q.empty()) {
int v = q.front();
q.pop();
for (auto i : adj[v]) {
if (!vis[i]) {
hops(s,i,dis[v] + 1);
vis[i] = 1;
dis[i] = dis[v] + 1;
q.push(i);
}
}
}
memset(vis,0,sizeof vis);
memset(dis,0,sizeof dis);
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
357 ms |
14912 KB |
Output is partially correct - 177660 call(s) of encode_bit() |
2 |
Correct |
11 ms |
4736 KB |
Output is correct - 90 call(s) of encode_bit() |
3 |
Correct |
31 ms |
6272 KB |
Output is correct - 43520 call(s) of encode_bit() |
4 |
Correct |
11 ms |
4736 KB |
Output is correct - 120 call(s) of encode_bit() |
5 |
Correct |
46 ms |
7168 KB |
Output is partially correct - 100830 call(s) of encode_bit() |
6 |
Correct |
48 ms |
7260 KB |
Output is partially correct - 104010 call(s) of encode_bit() |
7 |
Correct |
97 ms |
8304 KB |
Output is partially correct - 190790 call(s) of encode_bit() |
8 |
Correct |
30 ms |
6228 KB |
Output is correct - 27620 call(s) of encode_bit() |
9 |
Correct |
32 ms |
6464 KB |
Output is correct - 30090 call(s) of encode_bit() |
10 |
Correct |
32 ms |
6280 KB |
Output is correct - 29290 call(s) of encode_bit() |
11 |
Correct |
39 ms |
6656 KB |
Output is correct - 57160 call(s) of encode_bit() |
12 |
Correct |
28 ms |
6144 KB |
Output is correct - 19740 call(s) of encode_bit() |
13 |
Correct |
87 ms |
8108 KB |
Output is partially correct - 130750 call(s) of encode_bit() |
14 |
Correct |
34 ms |
6496 KB |
Output is correct - 32610 call(s) of encode_bit() |
15 |
Correct |
34 ms |
6400 KB |
Output is correct - 33950 call(s) of encode_bit() |
16 |
Correct |
71 ms |
7160 KB |
Output is correct - 63370 call(s) of encode_bit() |
17 |
Correct |
52 ms |
7160 KB |
Output is correct - 59560 call(s) of encode_bit() |
18 |
Correct |
73 ms |
7872 KB |
Output is partially correct - 91120 call(s) of encode_bit() |
19 |
Correct |
55 ms |
7356 KB |
Output is partially correct - 95320 call(s) of encode_bit() |
20 |
Correct |
88 ms |
8312 KB |
Output is partially correct - 114840 call(s) of encode_bit() |
21 |
Correct |
96 ms |
8520 KB |
Output is partially correct - 121400 call(s) of encode_bit() |
22 |
Correct |
82 ms |
8440 KB |
Output is partially correct - 178520 call(s) of encode_bit() |
23 |
Correct |
126 ms |
9248 KB |
Output is partially correct - 165950 call(s) of encode_bit() |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
357 ms |
14912 KB |
Output is partially correct - 177660 call(s) of encode_bit() |
2 |
Correct |
11 ms |
4736 KB |
Output is correct - 90 call(s) of encode_bit() |
3 |
Correct |
31 ms |
6272 KB |
Output is correct - 43520 call(s) of encode_bit() |
4 |
Correct |
11 ms |
4736 KB |
Output is correct - 120 call(s) of encode_bit() |
5 |
Correct |
46 ms |
7168 KB |
Output is partially correct - 100830 call(s) of encode_bit() |
6 |
Correct |
48 ms |
7260 KB |
Output is partially correct - 104010 call(s) of encode_bit() |
7 |
Correct |
97 ms |
8304 KB |
Output is partially correct - 190790 call(s) of encode_bit() |
8 |
Correct |
30 ms |
6228 KB |
Output is correct - 27620 call(s) of encode_bit() |
9 |
Correct |
32 ms |
6464 KB |
Output is correct - 30090 call(s) of encode_bit() |
10 |
Correct |
32 ms |
6280 KB |
Output is correct - 29290 call(s) of encode_bit() |
11 |
Correct |
39 ms |
6656 KB |
Output is correct - 57160 call(s) of encode_bit() |
12 |
Correct |
28 ms |
6144 KB |
Output is correct - 19740 call(s) of encode_bit() |
13 |
Correct |
87 ms |
8108 KB |
Output is partially correct - 130750 call(s) of encode_bit() |
14 |
Correct |
34 ms |
6496 KB |
Output is correct - 32610 call(s) of encode_bit() |
15 |
Correct |
34 ms |
6400 KB |
Output is correct - 33950 call(s) of encode_bit() |
16 |
Correct |
71 ms |
7160 KB |
Output is correct - 63370 call(s) of encode_bit() |
17 |
Correct |
52 ms |
7160 KB |
Output is correct - 59560 call(s) of encode_bit() |
18 |
Correct |
73 ms |
7872 KB |
Output is partially correct - 91120 call(s) of encode_bit() |
19 |
Correct |
55 ms |
7356 KB |
Output is partially correct - 95320 call(s) of encode_bit() |
20 |
Correct |
88 ms |
8312 KB |
Output is partially correct - 114840 call(s) of encode_bit() |
21 |
Correct |
96 ms |
8520 KB |
Output is partially correct - 121400 call(s) of encode_bit() |
22 |
Correct |
82 ms |
8440 KB |
Output is partially correct - 178520 call(s) of encode_bit() |
23 |
Correct |
126 ms |
9248 KB |
Output is partially correct - 165950 call(s) of encode_bit() |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
357 ms |
14912 KB |
Output is partially correct - 177660 call(s) of encode_bit() |
2 |
Correct |
11 ms |
4736 KB |
Output is correct - 90 call(s) of encode_bit() |
3 |
Correct |
31 ms |
6272 KB |
Output is correct - 43520 call(s) of encode_bit() |
4 |
Correct |
11 ms |
4736 KB |
Output is correct - 120 call(s) of encode_bit() |
5 |
Correct |
46 ms |
7168 KB |
Output is partially correct - 100830 call(s) of encode_bit() |
6 |
Correct |
48 ms |
7260 KB |
Output is partially correct - 104010 call(s) of encode_bit() |
7 |
Correct |
97 ms |
8304 KB |
Output is partially correct - 190790 call(s) of encode_bit() |
8 |
Correct |
30 ms |
6228 KB |
Output is correct - 27620 call(s) of encode_bit() |
9 |
Correct |
32 ms |
6464 KB |
Output is correct - 30090 call(s) of encode_bit() |
10 |
Correct |
32 ms |
6280 KB |
Output is correct - 29290 call(s) of encode_bit() |
11 |
Correct |
39 ms |
6656 KB |
Output is correct - 57160 call(s) of encode_bit() |
12 |
Correct |
28 ms |
6144 KB |
Output is correct - 19740 call(s) of encode_bit() |
13 |
Correct |
87 ms |
8108 KB |
Output is partially correct - 130750 call(s) of encode_bit() |
14 |
Correct |
34 ms |
6496 KB |
Output is correct - 32610 call(s) of encode_bit() |
15 |
Correct |
34 ms |
6400 KB |
Output is correct - 33950 call(s) of encode_bit() |
16 |
Correct |
71 ms |
7160 KB |
Output is correct - 63370 call(s) of encode_bit() |
17 |
Correct |
52 ms |
7160 KB |
Output is correct - 59560 call(s) of encode_bit() |
18 |
Correct |
73 ms |
7872 KB |
Output is partially correct - 91120 call(s) of encode_bit() |
19 |
Correct |
55 ms |
7356 KB |
Output is partially correct - 95320 call(s) of encode_bit() |
20 |
Correct |
88 ms |
8312 KB |
Output is partially correct - 114840 call(s) of encode_bit() |
21 |
Correct |
96 ms |
8520 KB |
Output is partially correct - 121400 call(s) of encode_bit() |
22 |
Correct |
82 ms |
8440 KB |
Output is partially correct - 178520 call(s) of encode_bit() |
23 |
Correct |
126 ms |
9248 KB |
Output is partially correct - 165950 call(s) of encode_bit() |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
357 ms |
14912 KB |
Output is partially correct - 177660 call(s) of encode_bit() |
2 |
Correct |
11 ms |
4736 KB |
Output is correct - 90 call(s) of encode_bit() |
3 |
Correct |
31 ms |
6272 KB |
Output is correct - 43520 call(s) of encode_bit() |
4 |
Correct |
11 ms |
4736 KB |
Output is correct - 120 call(s) of encode_bit() |
5 |
Correct |
46 ms |
7168 KB |
Output is partially correct - 100830 call(s) of encode_bit() |
6 |
Correct |
48 ms |
7260 KB |
Output is partially correct - 104010 call(s) of encode_bit() |
7 |
Correct |
97 ms |
8304 KB |
Output is partially correct - 190790 call(s) of encode_bit() |
8 |
Correct |
30 ms |
6228 KB |
Output is correct - 27620 call(s) of encode_bit() |
9 |
Correct |
32 ms |
6464 KB |
Output is correct - 30090 call(s) of encode_bit() |
10 |
Correct |
32 ms |
6280 KB |
Output is correct - 29290 call(s) of encode_bit() |
11 |
Correct |
39 ms |
6656 KB |
Output is correct - 57160 call(s) of encode_bit() |
12 |
Correct |
28 ms |
6144 KB |
Output is correct - 19740 call(s) of encode_bit() |
13 |
Correct |
87 ms |
8108 KB |
Output is partially correct - 130750 call(s) of encode_bit() |
14 |
Correct |
34 ms |
6496 KB |
Output is correct - 32610 call(s) of encode_bit() |
15 |
Correct |
34 ms |
6400 KB |
Output is correct - 33950 call(s) of encode_bit() |
16 |
Correct |
71 ms |
7160 KB |
Output is correct - 63370 call(s) of encode_bit() |
17 |
Correct |
52 ms |
7160 KB |
Output is correct - 59560 call(s) of encode_bit() |
18 |
Correct |
73 ms |
7872 KB |
Output is partially correct - 91120 call(s) of encode_bit() |
19 |
Correct |
55 ms |
7356 KB |
Output is partially correct - 95320 call(s) of encode_bit() |
20 |
Correct |
88 ms |
8312 KB |
Output is partially correct - 114840 call(s) of encode_bit() |
21 |
Correct |
96 ms |
8520 KB |
Output is partially correct - 121400 call(s) of encode_bit() |
22 |
Correct |
82 ms |
8440 KB |
Output is partially correct - 178520 call(s) of encode_bit() |
23 |
Correct |
126 ms |
9248 KB |
Output is partially correct - 165950 call(s) of encode_bit() |