Submission #476560

# Submission time Handle Problem Language Result Execution time Memory
476560 2021-09-27T15:49:34 Z AdamGS Saveit (IOI10_saveit) C++14
50 / 100
263 ms 13360 KB
#include "grader.h"
#include "encoder.h"
#include<bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
#define rep(a, b) for(int a = 0; a < (b); ++a)
#define st first
#define nd second
#define pb push_back
#define all(a) a.begin(), a.end()
const int LIM=1e3+7, INF=1e9+7;
vector<ll>V[LIM], P;
ll oc[LIM], odw[LIM], odl[LIM];
void DFS(int x) {
	P.pb(x);
	odw[x]=1;
	sort(all(V[x]));
	for(auto i : V[x]) if(!odw[i]) {
		oc[i]=x;
		DFS(i);
	}
}
void encode(int n, int h, int m, int *a, int *b) {
	rep(i, m) {
		V[a[i]].pb(b[i]);
		V[b[i]].pb(a[i]);
	}
	DFS(0);
	rep(i, n-1) rep(j, 10) encode_bit((oc[i+1]&(1<<j))>0);
	rep(i, h) {
		rep(j, n) odl[j]=INF;
		queue<int>q;
		q.push(i);
		odl[i]=0;
		while(!q.empty()) {
			int p=q.front(); q.pop();
			for(auto j : V[p]) if(odl[j]>odl[p]+1) {
				odl[j]=odl[p]+1;
				q.push(j);
			}
		}
		rep(j, 10) encode_bit((odl[0]&(1<<j))>0);
		rep(j, P.size()-1) {
			int x=odl[P[j+1]]-odl[oc[P[j+1]]]+1;
			rep(l, 2) encode_bit((x&(1<<l))>0);
		}
	}
}
#include "grader.h"
#include "decoder.h"
#include<bits/stdc++.h>
using namespace std;
typedef long double ld;
#define rep(a, b) for(int a = 0; a < (b); ++a)
#define st first
#define nd second
#define pb push_back
#define all(a) a.begin(), a.end()
const int LIM=1e3+7;
vector<int>V[LIM], P;
int odw[LIM], oc[LIM], odl[LIM];
void DFS(int x) {
	P.pb(x);
	odw[x]=1;
	sort(all(V[x]));
	for(auto i : V[x]) if(!odw[i]) DFS(i);
}
void decode(int n, int h) {
	rep(i, n-1) {
		int x=0;
		rep(j, 10) x+=decode_bit()*(1<<j);
		oc[i+1]=x;
		V[i+1].pb(x);
		V[x].pb(i+1);
	}
	DFS(0);
	rep(i, h) {
		rep(j, n) odl[j]=0;
		rep(j, 10) odl[0]+=decode_bit()*(1<<j);
		rep(j, P.size()-1) {
			int x=0;
			rep(l, 2) x+=decode_bit()*(1<<l);
			--x;
			odl[P[j+1]]=odl[oc[P[j+1]]]+x;
		}
		rep(j, n) hops(i, j, odl[j]);
	}
}

Compilation message

encoder.cpp: In function 'void encode(int, int, int, int*, int*)':
encoder.cpp:7:36: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    7 | #define rep(a, b) for(int a = 0; a < (b); ++a)
      |                                    ^
encoder.cpp:44:3: note: in expansion of macro 'rep'
   44 |   rep(j, P.size()-1) {
      |   ^~~

decoder.cpp: In function 'void decode(int, int)':
decoder.cpp:6:36: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    6 | #define rep(a, b) for(int a = 0; a < (b); ++a)
      |                                    ^
decoder.cpp:32:3: note: in expansion of macro 'rep'
   32 |   rep(j, P.size()-1) {
      |   ^~~
# Verdict Execution time Memory Grader output
1 Correct 263 ms 13360 KB Output is partially correct - 82278 call(s) of encode_bit()
2 Correct 2 ms 4580 KB Output is correct - 94 call(s) of encode_bit()
3 Correct 28 ms 5492 KB Output is partially correct - 74078 call(s) of encode_bit()
4 Correct 4 ms 4580 KB Output is correct - 130 call(s) of encode_bit()
5 Correct 26 ms 5760 KB Output is partially correct - 74078 call(s) of encode_bit()
6 Correct 36 ms 5796 KB Output is partially correct - 82278 call(s) of encode_bit()
7 Correct 55 ms 6352 KB Output is partially correct - 82278 call(s) of encode_bit()
8 Correct 26 ms 5528 KB Output is partially correct - 79080 call(s) of encode_bit()
9 Correct 28 ms 5596 KB Output is partially correct - 82278 call(s) of encode_bit()
10 Correct 25 ms 5540 KB Output is partially correct - 82278 call(s) of encode_bit()
11 Correct 34 ms 5892 KB Output is partially correct - 82278 call(s) of encode_bit()
12 Correct 25 ms 5668 KB Output is partially correct - 82278 call(s) of encode_bit()
13 Correct 62 ms 6652 KB Output is partially correct - 82278 call(s) of encode_bit()
14 Correct 25 ms 5712 KB Output is partially correct - 82278 call(s) of encode_bit()
15 Correct 31 ms 5540 KB Output is partially correct - 82278 call(s) of encode_bit()
16 Correct 62 ms 6592 KB Output is partially correct - 82278 call(s) of encode_bit()
17 Correct 56 ms 6420 KB Output is partially correct - 82278 call(s) of encode_bit()
18 Correct 71 ms 6792 KB Output is partially correct - 82278 call(s) of encode_bit()
19 Correct 52 ms 6048 KB Output is partially correct - 82278 call(s) of encode_bit()
20 Correct 92 ms 7268 KB Output is partially correct - 82278 call(s) of encode_bit()
21 Correct 88 ms 7432 KB Output is partially correct - 82278 call(s) of encode_bit()
22 Correct 62 ms 6960 KB Output is partially correct - 82278 call(s) of encode_bit()
23 Correct 90 ms 7968 KB Output is partially correct - 82278 call(s) of encode_bit()
# Verdict Execution time Memory Grader output
1 Correct 263 ms 13360 KB Output is partially correct - 82278 call(s) of encode_bit()
2 Correct 2 ms 4580 KB Output is correct - 94 call(s) of encode_bit()
3 Correct 28 ms 5492 KB Output is partially correct - 74078 call(s) of encode_bit()
4 Correct 4 ms 4580 KB Output is correct - 130 call(s) of encode_bit()
5 Correct 26 ms 5760 KB Output is partially correct - 74078 call(s) of encode_bit()
6 Correct 36 ms 5796 KB Output is partially correct - 82278 call(s) of encode_bit()
7 Correct 55 ms 6352 KB Output is partially correct - 82278 call(s) of encode_bit()
8 Correct 26 ms 5528 KB Output is partially correct - 79080 call(s) of encode_bit()
9 Correct 28 ms 5596 KB Output is partially correct - 82278 call(s) of encode_bit()
10 Correct 25 ms 5540 KB Output is partially correct - 82278 call(s) of encode_bit()
11 Correct 34 ms 5892 KB Output is partially correct - 82278 call(s) of encode_bit()
12 Correct 25 ms 5668 KB Output is partially correct - 82278 call(s) of encode_bit()
13 Correct 62 ms 6652 KB Output is partially correct - 82278 call(s) of encode_bit()
14 Correct 25 ms 5712 KB Output is partially correct - 82278 call(s) of encode_bit()
15 Correct 31 ms 5540 KB Output is partially correct - 82278 call(s) of encode_bit()
16 Correct 62 ms 6592 KB Output is partially correct - 82278 call(s) of encode_bit()
17 Correct 56 ms 6420 KB Output is partially correct - 82278 call(s) of encode_bit()
18 Correct 71 ms 6792 KB Output is partially correct - 82278 call(s) of encode_bit()
19 Correct 52 ms 6048 KB Output is partially correct - 82278 call(s) of encode_bit()
20 Correct 92 ms 7268 KB Output is partially correct - 82278 call(s) of encode_bit()
21 Correct 88 ms 7432 KB Output is partially correct - 82278 call(s) of encode_bit()
22 Correct 62 ms 6960 KB Output is partially correct - 82278 call(s) of encode_bit()
23 Correct 90 ms 7968 KB Output is partially correct - 82278 call(s) of encode_bit()
# Verdict Execution time Memory Grader output
1 Correct 263 ms 13360 KB Output is partially correct - 82278 call(s) of encode_bit()
2 Correct 2 ms 4580 KB Output is correct - 94 call(s) of encode_bit()
3 Correct 28 ms 5492 KB Output is partially correct - 74078 call(s) of encode_bit()
4 Correct 4 ms 4580 KB Output is correct - 130 call(s) of encode_bit()
5 Correct 26 ms 5760 KB Output is partially correct - 74078 call(s) of encode_bit()
6 Correct 36 ms 5796 KB Output is partially correct - 82278 call(s) of encode_bit()
7 Correct 55 ms 6352 KB Output is partially correct - 82278 call(s) of encode_bit()
8 Correct 26 ms 5528 KB Output is partially correct - 79080 call(s) of encode_bit()
9 Correct 28 ms 5596 KB Output is partially correct - 82278 call(s) of encode_bit()
10 Correct 25 ms 5540 KB Output is partially correct - 82278 call(s) of encode_bit()
11 Correct 34 ms 5892 KB Output is partially correct - 82278 call(s) of encode_bit()
12 Correct 25 ms 5668 KB Output is partially correct - 82278 call(s) of encode_bit()
13 Correct 62 ms 6652 KB Output is partially correct - 82278 call(s) of encode_bit()
14 Correct 25 ms 5712 KB Output is partially correct - 82278 call(s) of encode_bit()
15 Correct 31 ms 5540 KB Output is partially correct - 82278 call(s) of encode_bit()
16 Correct 62 ms 6592 KB Output is partially correct - 82278 call(s) of encode_bit()
17 Correct 56 ms 6420 KB Output is partially correct - 82278 call(s) of encode_bit()
18 Correct 71 ms 6792 KB Output is partially correct - 82278 call(s) of encode_bit()
19 Correct 52 ms 6048 KB Output is partially correct - 82278 call(s) of encode_bit()
20 Correct 92 ms 7268 KB Output is partially correct - 82278 call(s) of encode_bit()
21 Correct 88 ms 7432 KB Output is partially correct - 82278 call(s) of encode_bit()
22 Correct 62 ms 6960 KB Output is partially correct - 82278 call(s) of encode_bit()
23 Correct 90 ms 7968 KB Output is partially correct - 82278 call(s) of encode_bit()
# Verdict Execution time Memory Grader output
1 Correct 263 ms 13360 KB Output is partially correct - 82278 call(s) of encode_bit()
2 Correct 2 ms 4580 KB Output is correct - 94 call(s) of encode_bit()
3 Correct 28 ms 5492 KB Output is partially correct - 74078 call(s) of encode_bit()
4 Correct 4 ms 4580 KB Output is correct - 130 call(s) of encode_bit()
5 Correct 26 ms 5760 KB Output is partially correct - 74078 call(s) of encode_bit()
6 Correct 36 ms 5796 KB Output is partially correct - 82278 call(s) of encode_bit()
7 Correct 55 ms 6352 KB Output is partially correct - 82278 call(s) of encode_bit()
8 Correct 26 ms 5528 KB Output is partially correct - 79080 call(s) of encode_bit()
9 Correct 28 ms 5596 KB Output is partially correct - 82278 call(s) of encode_bit()
10 Correct 25 ms 5540 KB Output is partially correct - 82278 call(s) of encode_bit()
11 Correct 34 ms 5892 KB Output is partially correct - 82278 call(s) of encode_bit()
12 Correct 25 ms 5668 KB Output is partially correct - 82278 call(s) of encode_bit()
13 Correct 62 ms 6652 KB Output is partially correct - 82278 call(s) of encode_bit()
14 Correct 25 ms 5712 KB Output is partially correct - 82278 call(s) of encode_bit()
15 Correct 31 ms 5540 KB Output is partially correct - 82278 call(s) of encode_bit()
16 Correct 62 ms 6592 KB Output is partially correct - 82278 call(s) of encode_bit()
17 Correct 56 ms 6420 KB Output is partially correct - 82278 call(s) of encode_bit()
18 Correct 71 ms 6792 KB Output is partially correct - 82278 call(s) of encode_bit()
19 Correct 52 ms 6048 KB Output is partially correct - 82278 call(s) of encode_bit()
20 Correct 92 ms 7268 KB Output is partially correct - 82278 call(s) of encode_bit()
21 Correct 88 ms 7432 KB Output is partially correct - 82278 call(s) of encode_bit()
22 Correct 62 ms 6960 KB Output is partially correct - 82278 call(s) of encode_bit()
23 Correct 90 ms 7968 KB Output is partially correct - 82278 call(s) of encode_bit()