# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
718861 |
2023-04-05T02:50:12 Z |
lam |
Saveit (IOI10_saveit) |
C++14 |
|
208 ms |
10372 KB |
#include "grader.h"
#include "encoder.h"
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1010;
int n;
int par[maxn];
int d[36][maxn];
vector <int> adj[maxn];
void bfs(int rt, bool keep)
{
queue<int> q;
fill_n(d[rt],n,-1);
d[rt][rt] = 0;
q.push(rt);
if (keep) par[rt] = rt;
while (!q.empty())
{
int u=q.front(); q.pop();
for (int v:adj[u])
if (d[rt][v] == -1)
{
d[rt][v] = d[rt][u] + 1;
if (keep) par[v] = u;
q.push(v);
}
}
}
inline bool checkbit(int i, int j)
{
return i>>j&1;
}
void encode(int nv, int nh, int ne, int *v1, int *v2){
n=nv;
for (int i=0; i<n; i++) adj[i].clear();
for (int i=0; i<ne; i++)
{
int u=v1[i]; int v=v2[i];
adj[u].push_back(v);
adj[v].push_back(u);
}
for (int i=0; i<nh; i++) bfs(i,(i==0));
for (int i=0; i<n; i++)
for (int j=0; j<10; j++)
encode_bit(checkbit(par[i],j));
par[n]=par[n+1]=par[n+2]=0;
for (int rt=1; rt<nh; rt++)
for (int i=1; i<n; i+=3)
{
int u,v;
u=i; v=par[i];
int t1 = (d[rt][u]==d[rt][v])?0:((d[rt][u]>d[rt][v])?1:2);
u=i+1; v=par[i+1];
int t2 = (d[rt][u]==d[rt][v])?0:((d[rt][u]>d[rt][v])?1:2);
u=i+2; v=par[i+2];
int t3 = (d[rt][u]==d[rt][v])?0:((d[rt][u]>d[rt][v])?1:2);
int T = t1+t2*3+t3*9;
for (int z=0; z<=5; z++) encode_bit(checkbit(T,z));
}
}
#include "grader.h"
#include "decoder.h"
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1010;
int n,rt;
vector <int> adj[maxn];
int par[maxn];
int d[maxn],t[maxn],ans[maxn];
void BFS()
{
queue<int> q;
fill_n(d,n,-1);
d[0] = 0;
q.push(0);
while (!q.empty())
{
int u=q.front(); q.pop();
for (int v:adj[u])
if (d[v]==-1)
{
d[v]=d[u]+1;
q.push(v);
}
}
}
void dfs(int x, int p)
{
for (int i:adj[x])
if (i!=p)
{
if (t[i]==0) ans[i]=ans[x];
else if (t[i]==1) ans[i]=ans[x]+1;
else ans[i]=ans[x]-1;
dfs(i,x);
}
}
void decode(int nv, int nh) {
n=nv; rt = 0;
for (int i=0; i<n; i++)
{
int x=0;
for (int j=0; j<10; j++) if (decode_bit()) x|=(1<<j);
par[i] = x;
adj[par[i]].push_back(x);
}
for (int i=0; i<n; i++) hops(rt,i,d[i]);
for (int st = 1; st<nh; st++)
{
for (int i=1; i<n; i+=3)
{
int T = 0;
for (int z=0; z<5; z++) if (decode_bit()) T |= (1<<z);
int t1 = T%3; T/=3;
int t2 = T%3; T/=3;
int t3 = T%3; T/=3;
t[i]=t1; t[i+1]=t2; t[i+2]=t3;
}
ans[0] = d[st];
dfs(0,0);
for (int i=0; i<n; i++) hops(st,i,ans[i]);
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
208 ms |
10372 KB |
Output isn't correct |
2 |
Incorrect |
3 ms |
4604 KB |
Output isn't correct |
3 |
Incorrect |
19 ms |
5628 KB |
Output isn't correct |
4 |
Incorrect |
2 ms |
4604 KB |
Output isn't correct |
5 |
Incorrect |
22 ms |
5668 KB |
Output isn't correct |
6 |
Incorrect |
24 ms |
5672 KB |
Output isn't correct |
7 |
Incorrect |
46 ms |
6192 KB |
Output isn't correct |
8 |
Incorrect |
20 ms |
5568 KB |
Output isn't correct |
9 |
Incorrect |
26 ms |
5700 KB |
Output isn't correct |
10 |
Incorrect |
20 ms |
5624 KB |
Output isn't correct |
11 |
Incorrect |
28 ms |
5740 KB |
Output isn't correct |
12 |
Incorrect |
20 ms |
5636 KB |
Output isn't correct |
13 |
Incorrect |
45 ms |
6248 KB |
Output isn't correct |
14 |
Incorrect |
26 ms |
5652 KB |
Output isn't correct |
15 |
Incorrect |
23 ms |
5712 KB |
Output isn't correct |
16 |
Incorrect |
44 ms |
6036 KB |
Output isn't correct |
17 |
Incorrect |
41 ms |
6084 KB |
Output isn't correct |
18 |
Incorrect |
55 ms |
6316 KB |
Output isn't correct |
19 |
Incorrect |
41 ms |
5888 KB |
Output isn't correct |
20 |
Incorrect |
57 ms |
6604 KB |
Output isn't correct |
21 |
Incorrect |
87 ms |
6668 KB |
Output isn't correct |
22 |
Incorrect |
57 ms |
6268 KB |
Output isn't correct |
23 |
Incorrect |
76 ms |
6968 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
208 ms |
10372 KB |
Output isn't correct |
2 |
Incorrect |
3 ms |
4604 KB |
Output isn't correct |
3 |
Incorrect |
19 ms |
5628 KB |
Output isn't correct |
4 |
Incorrect |
2 ms |
4604 KB |
Output isn't correct |
5 |
Incorrect |
22 ms |
5668 KB |
Output isn't correct |
6 |
Incorrect |
24 ms |
5672 KB |
Output isn't correct |
7 |
Incorrect |
46 ms |
6192 KB |
Output isn't correct |
8 |
Incorrect |
20 ms |
5568 KB |
Output isn't correct |
9 |
Incorrect |
26 ms |
5700 KB |
Output isn't correct |
10 |
Incorrect |
20 ms |
5624 KB |
Output isn't correct |
11 |
Incorrect |
28 ms |
5740 KB |
Output isn't correct |
12 |
Incorrect |
20 ms |
5636 KB |
Output isn't correct |
13 |
Incorrect |
45 ms |
6248 KB |
Output isn't correct |
14 |
Incorrect |
26 ms |
5652 KB |
Output isn't correct |
15 |
Incorrect |
23 ms |
5712 KB |
Output isn't correct |
16 |
Incorrect |
44 ms |
6036 KB |
Output isn't correct |
17 |
Incorrect |
41 ms |
6084 KB |
Output isn't correct |
18 |
Incorrect |
55 ms |
6316 KB |
Output isn't correct |
19 |
Incorrect |
41 ms |
5888 KB |
Output isn't correct |
20 |
Incorrect |
57 ms |
6604 KB |
Output isn't correct |
21 |
Incorrect |
87 ms |
6668 KB |
Output isn't correct |
22 |
Incorrect |
57 ms |
6268 KB |
Output isn't correct |
23 |
Incorrect |
76 ms |
6968 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
208 ms |
10372 KB |
Output isn't correct |
2 |
Incorrect |
3 ms |
4604 KB |
Output isn't correct |
3 |
Incorrect |
19 ms |
5628 KB |
Output isn't correct |
4 |
Incorrect |
2 ms |
4604 KB |
Output isn't correct |
5 |
Incorrect |
22 ms |
5668 KB |
Output isn't correct |
6 |
Incorrect |
24 ms |
5672 KB |
Output isn't correct |
7 |
Incorrect |
46 ms |
6192 KB |
Output isn't correct |
8 |
Incorrect |
20 ms |
5568 KB |
Output isn't correct |
9 |
Incorrect |
26 ms |
5700 KB |
Output isn't correct |
10 |
Incorrect |
20 ms |
5624 KB |
Output isn't correct |
11 |
Incorrect |
28 ms |
5740 KB |
Output isn't correct |
12 |
Incorrect |
20 ms |
5636 KB |
Output isn't correct |
13 |
Incorrect |
45 ms |
6248 KB |
Output isn't correct |
14 |
Incorrect |
26 ms |
5652 KB |
Output isn't correct |
15 |
Incorrect |
23 ms |
5712 KB |
Output isn't correct |
16 |
Incorrect |
44 ms |
6036 KB |
Output isn't correct |
17 |
Incorrect |
41 ms |
6084 KB |
Output isn't correct |
18 |
Incorrect |
55 ms |
6316 KB |
Output isn't correct |
19 |
Incorrect |
41 ms |
5888 KB |
Output isn't correct |
20 |
Incorrect |
57 ms |
6604 KB |
Output isn't correct |
21 |
Incorrect |
87 ms |
6668 KB |
Output isn't correct |
22 |
Incorrect |
57 ms |
6268 KB |
Output isn't correct |
23 |
Incorrect |
76 ms |
6968 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
208 ms |
10372 KB |
Output isn't correct |
2 |
Incorrect |
3 ms |
4604 KB |
Output isn't correct |
3 |
Incorrect |
19 ms |
5628 KB |
Output isn't correct |
4 |
Incorrect |
2 ms |
4604 KB |
Output isn't correct |
5 |
Incorrect |
22 ms |
5668 KB |
Output isn't correct |
6 |
Incorrect |
24 ms |
5672 KB |
Output isn't correct |
7 |
Incorrect |
46 ms |
6192 KB |
Output isn't correct |
8 |
Incorrect |
20 ms |
5568 KB |
Output isn't correct |
9 |
Incorrect |
26 ms |
5700 KB |
Output isn't correct |
10 |
Incorrect |
20 ms |
5624 KB |
Output isn't correct |
11 |
Incorrect |
28 ms |
5740 KB |
Output isn't correct |
12 |
Incorrect |
20 ms |
5636 KB |
Output isn't correct |
13 |
Incorrect |
45 ms |
6248 KB |
Output isn't correct |
14 |
Incorrect |
26 ms |
5652 KB |
Output isn't correct |
15 |
Incorrect |
23 ms |
5712 KB |
Output isn't correct |
16 |
Incorrect |
44 ms |
6036 KB |
Output isn't correct |
17 |
Incorrect |
41 ms |
6084 KB |
Output isn't correct |
18 |
Incorrect |
55 ms |
6316 KB |
Output isn't correct |
19 |
Incorrect |
41 ms |
5888 KB |
Output isn't correct |
20 |
Incorrect |
57 ms |
6604 KB |
Output isn't correct |
21 |
Incorrect |
87 ms |
6668 KB |
Output isn't correct |
22 |
Incorrect |
57 ms |
6268 KB |
Output isn't correct |
23 |
Incorrect |
76 ms |
6968 KB |
Output isn't correct |