Submission #803074

# Submission time Handle Problem Language Result Execution time Memory
803074 2023-08-02T21:15:36 Z Antekb Saveit (IOI10_saveit) C++17
50 / 100
821 ms 13544 KB
#include "grader.h"
#include "encoder.h"
#include<bits/stdc++.h>
#define st first
#define nd second
#define pb push_back
#define pp pop_back;
using namespace std;
using vi = vector<int>;
using pii = pair<int, int>;
void nadaj(int x, int b){
	for(int i=0; i<b; i++){
		encode_bit(!!(x&(1<<i)));
	}
}
void encode(int n, int h, int m, int *v1, int *v2){
	vi E[n];
	int czy[n][h], dist[n][h];
	for(int i=0; i<n; i++){
		for(int j=0; j<h; j++){
			czy[i][j]=(i==j);
			dist[i][j]=1e9*(i!=j);
		}
	}
	vi edg;
	for(int i=0; i<m; i++){
		E[v1[i]].pb(edg.size());
		edg.pb(v2[i]);
		E[v2[i]].pb(edg.size());
		edg.pb(v1[i]);
	}
	for(int s=0; s<h; s++){
		vi V;
		V.pb(s);
		for(int i=0; i<V.size(); i++){
			int v=V[i];
			for(int e:E[v]){
				if(dist[edg[e]][s]==1e9){
					dist[edg[e]][s]=dist[v][s]+1;
					V.pb(edg[e]);
				}
			}
		}
	}
	vi E2[n];
	for(int v=0; v<n; v++){
		int ile=0;
		for(int e:E[v]){
			int u=edg[e];
			bool b=0;
			for(int i=0; i<h; i++){
				if(!czy[u][i] && dist[u][i]==dist[v][i]+1){
					b=1;
				}
				if(!czy[v][i] && dist[v][i]==dist[u][i]+1){
					b=1;
				}
			}
			if(b)ile++;
		}
		if(ile>=100){
			for(int e:E[v]){
				int u=edg[e];
				for(int i=0; i<h; i++){
					if(!czy[u][i] && dist[u][i]==dist[v][i]+1){
						czy[u][i]=1;
						E2[v].pb(u);
					}
					if(!czy[v][i] && dist[v][i]==dist[u][i]+1){
						czy[v][i]=1;
						E2[v].pb(u);
					}
				}
			}
		}
	}
	int sum=0;
	vi kol(m);
	for(int i=0; i<m; i++)kol[i]=i;
	shuffle(kol.begin(), kol.end(), (mt19937)(4));
	for(int t=h; t>0; t--){
		for(int e:kol){
			int u=v1[e], v=v2[e];
			int ile=0;
			for(int i=0; i<h; i++){
				if(!czy[u][i] && dist[u][i]==dist[v][i]+1){
					ile++;
				}
				if(!czy[v][i] && dist[v][i]==dist[u][i]+1){
					ile++;
				}
			}
			if(ile==t){
				//cerr<<t<<"\n";
				sum+=t;
				E2[v].pb(u);
				for(int i=0; i<h; i++){
					if(!czy[u][i] && dist[u][i]==dist[v][i]+1){
						czy[u][i]=1;
					}
					if(!czy[v][i] && dist[v][i]==dist[u][i]+1){
						czy[v][i]=1;
					}
				}
			}
		}
	}
	cerr<<sum<<"\n";
	for(int i=0; i<n; i++){
		sort(E2[i].begin(), E2[i].end());
		nadaj(min((int)E2[i].size(), 100), 7);
		if(E2[i].size()>=100){
			vi V(n);
			for(int u:E2[i]){
				V[u]=1;
			}
			for(int j:V){
				nadaj(j, 1);
			}
		}
		else{
			for(int u:E2[i]){
				nadaj(u, 10);
			}
		}
	}
	return;
}
#include "grader.h"
#include "decoder.h"
#include<bits/stdc++.h>
#define st first
#define nd second
#define pb push_back
#define pp pop_back;
using namespace std;
using vi = vector<int>;
using pii = pair<int, int>;
int czytaj(int b){
	int x=0;
	for(int i=0; i<b; i++){
		x+=(int(decode_bit())<<i);
	}
	return x;
}
void decode(int n, int h) {
	vi E[n];
	for(int i=0;i<n; i++){
		int k=czytaj(7);
		//cerr<<k<<"\n";
		if(k==100){
			for(int j=0; j<n; j++){
				if(czytaj(1)){
					E[i].pb(j);
					E[j].pb(i);
				}
			}
		}
		else{
			while(k--){
				int j=czytaj(10);
				E[i].pb(j);
				E[j].pb(i);
			}
		}
	}
	for(int s=0; s<h; s++){
		vi V;
		V.pb(s);
		vi dist(n, 1e9);
		dist[s]=0;
		for(int i=0; i<V.size(); i++){
			int v=V[i];
			for(int u:E[v]){
				if(dist[u]==1e9){
					dist[u]=dist[v]+1;
					V.pb(u);
				}
			}
		}
		for(int i=0; i<n; i++){
			hops(s, i, dist[i]);
		}
	}
}

Compilation message

encoder.cpp: In function 'void encode(int, int, int, int*, int*)':
encoder.cpp:35:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   35 |   for(int i=0; i<V.size(); i++){
      |                ~^~~~~~~~~

decoder.cpp: In function 'void decode(int, int)':
decoder.cpp:44:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   44 |   for(int i=0; i<V.size(); i++){
      |                ~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 821 ms 13544 KB Output is correct - 43000 call(s) of encode_bit()
2 Correct 2 ms 4612 KB Output is correct - 105 call(s) of encode_bit()
3 Correct 38 ms 5536 KB Output is correct - 40780 call(s) of encode_bit()
4 Correct 3 ms 4600 KB Output is correct - 125 call(s) of encode_bit()
5 Correct 90 ms 5952 KB Output is partially correct - 80060 call(s) of encode_bit()
6 Correct 88 ms 6056 KB Output is partially correct - 81000 call(s) of encode_bit()
7 Correct 189 ms 7252 KB Output is partially correct - 130560 call(s) of encode_bit()
8 Correct 20 ms 5280 KB Output is correct - 22797 call(s) of encode_bit()
9 Correct 33 ms 5316 KB Output is correct - 22880 call(s) of encode_bit()
10 Correct 34 ms 5324 KB Output is correct - 22680 call(s) of encode_bit()
11 Correct 113 ms 5868 KB Output is correct - 41460 call(s) of encode_bit()
12 Correct 13 ms 5292 KB Output is correct - 16990 call(s) of encode_bit()
13 Correct 361 ms 7208 KB Output is partially correct - 93540 call(s) of encode_bit()
14 Correct 37 ms 5276 KB Output is correct - 25910 call(s) of encode_bit()
15 Correct 31 ms 5476 KB Output is correct - 28760 call(s) of encode_bit()
16 Correct 110 ms 6512 KB Output is correct - 34500 call(s) of encode_bit()
17 Correct 89 ms 6360 KB Output is correct - 33860 call(s) of encode_bit()
18 Correct 143 ms 6884 KB Output is correct - 60510 call(s) of encode_bit()
19 Correct 119 ms 6144 KB Output is correct - 56430 call(s) of encode_bit()
20 Correct 203 ms 7492 KB Output is partially correct - 73390 call(s) of encode_bit()
21 Correct 207 ms 7740 KB Output is partially correct - 73980 call(s) of encode_bit()
22 Correct 196 ms 7044 KB Output is partially correct - 100530 call(s) of encode_bit()
23 Correct 293 ms 8436 KB Output is partially correct - 108510 call(s) of encode_bit()
# Verdict Execution time Memory Grader output
1 Correct 821 ms 13544 KB Output is correct - 43000 call(s) of encode_bit()
2 Correct 2 ms 4612 KB Output is correct - 105 call(s) of encode_bit()
3 Correct 38 ms 5536 KB Output is correct - 40780 call(s) of encode_bit()
4 Correct 3 ms 4600 KB Output is correct - 125 call(s) of encode_bit()
5 Correct 90 ms 5952 KB Output is partially correct - 80060 call(s) of encode_bit()
6 Correct 88 ms 6056 KB Output is partially correct - 81000 call(s) of encode_bit()
7 Correct 189 ms 7252 KB Output is partially correct - 130560 call(s) of encode_bit()
8 Correct 20 ms 5280 KB Output is correct - 22797 call(s) of encode_bit()
9 Correct 33 ms 5316 KB Output is correct - 22880 call(s) of encode_bit()
10 Correct 34 ms 5324 KB Output is correct - 22680 call(s) of encode_bit()
11 Correct 113 ms 5868 KB Output is correct - 41460 call(s) of encode_bit()
12 Correct 13 ms 5292 KB Output is correct - 16990 call(s) of encode_bit()
13 Correct 361 ms 7208 KB Output is partially correct - 93540 call(s) of encode_bit()
14 Correct 37 ms 5276 KB Output is correct - 25910 call(s) of encode_bit()
15 Correct 31 ms 5476 KB Output is correct - 28760 call(s) of encode_bit()
16 Correct 110 ms 6512 KB Output is correct - 34500 call(s) of encode_bit()
17 Correct 89 ms 6360 KB Output is correct - 33860 call(s) of encode_bit()
18 Correct 143 ms 6884 KB Output is correct - 60510 call(s) of encode_bit()
19 Correct 119 ms 6144 KB Output is correct - 56430 call(s) of encode_bit()
20 Correct 203 ms 7492 KB Output is partially correct - 73390 call(s) of encode_bit()
21 Correct 207 ms 7740 KB Output is partially correct - 73980 call(s) of encode_bit()
22 Correct 196 ms 7044 KB Output is partially correct - 100530 call(s) of encode_bit()
23 Correct 293 ms 8436 KB Output is partially correct - 108510 call(s) of encode_bit()
# Verdict Execution time Memory Grader output
1 Correct 821 ms 13544 KB Output is correct - 43000 call(s) of encode_bit()
2 Correct 2 ms 4612 KB Output is correct - 105 call(s) of encode_bit()
3 Correct 38 ms 5536 KB Output is correct - 40780 call(s) of encode_bit()
4 Correct 3 ms 4600 KB Output is correct - 125 call(s) of encode_bit()
5 Correct 90 ms 5952 KB Output is partially correct - 80060 call(s) of encode_bit()
6 Correct 88 ms 6056 KB Output is partially correct - 81000 call(s) of encode_bit()
7 Correct 189 ms 7252 KB Output is partially correct - 130560 call(s) of encode_bit()
8 Correct 20 ms 5280 KB Output is correct - 22797 call(s) of encode_bit()
9 Correct 33 ms 5316 KB Output is correct - 22880 call(s) of encode_bit()
10 Correct 34 ms 5324 KB Output is correct - 22680 call(s) of encode_bit()
11 Correct 113 ms 5868 KB Output is correct - 41460 call(s) of encode_bit()
12 Correct 13 ms 5292 KB Output is correct - 16990 call(s) of encode_bit()
13 Correct 361 ms 7208 KB Output is partially correct - 93540 call(s) of encode_bit()
14 Correct 37 ms 5276 KB Output is correct - 25910 call(s) of encode_bit()
15 Correct 31 ms 5476 KB Output is correct - 28760 call(s) of encode_bit()
16 Correct 110 ms 6512 KB Output is correct - 34500 call(s) of encode_bit()
17 Correct 89 ms 6360 KB Output is correct - 33860 call(s) of encode_bit()
18 Correct 143 ms 6884 KB Output is correct - 60510 call(s) of encode_bit()
19 Correct 119 ms 6144 KB Output is correct - 56430 call(s) of encode_bit()
20 Correct 203 ms 7492 KB Output is partially correct - 73390 call(s) of encode_bit()
21 Correct 207 ms 7740 KB Output is partially correct - 73980 call(s) of encode_bit()
22 Correct 196 ms 7044 KB Output is partially correct - 100530 call(s) of encode_bit()
23 Correct 293 ms 8436 KB Output is partially correct - 108510 call(s) of encode_bit()
# Verdict Execution time Memory Grader output
1 Correct 821 ms 13544 KB Output is correct - 43000 call(s) of encode_bit()
2 Correct 2 ms 4612 KB Output is correct - 105 call(s) of encode_bit()
3 Correct 38 ms 5536 KB Output is correct - 40780 call(s) of encode_bit()
4 Correct 3 ms 4600 KB Output is correct - 125 call(s) of encode_bit()
5 Correct 90 ms 5952 KB Output is partially correct - 80060 call(s) of encode_bit()
6 Correct 88 ms 6056 KB Output is partially correct - 81000 call(s) of encode_bit()
7 Correct 189 ms 7252 KB Output is partially correct - 130560 call(s) of encode_bit()
8 Correct 20 ms 5280 KB Output is correct - 22797 call(s) of encode_bit()
9 Correct 33 ms 5316 KB Output is correct - 22880 call(s) of encode_bit()
10 Correct 34 ms 5324 KB Output is correct - 22680 call(s) of encode_bit()
11 Correct 113 ms 5868 KB Output is correct - 41460 call(s) of encode_bit()
12 Correct 13 ms 5292 KB Output is correct - 16990 call(s) of encode_bit()
13 Correct 361 ms 7208 KB Output is partially correct - 93540 call(s) of encode_bit()
14 Correct 37 ms 5276 KB Output is correct - 25910 call(s) of encode_bit()
15 Correct 31 ms 5476 KB Output is correct - 28760 call(s) of encode_bit()
16 Correct 110 ms 6512 KB Output is correct - 34500 call(s) of encode_bit()
17 Correct 89 ms 6360 KB Output is correct - 33860 call(s) of encode_bit()
18 Correct 143 ms 6884 KB Output is correct - 60510 call(s) of encode_bit()
19 Correct 119 ms 6144 KB Output is correct - 56430 call(s) of encode_bit()
20 Correct 203 ms 7492 KB Output is partially correct - 73390 call(s) of encode_bit()
21 Correct 207 ms 7740 KB Output is partially correct - 73980 call(s) of encode_bit()
22 Correct 196 ms 7044 KB Output is partially correct - 100530 call(s) of encode_bit()
23 Correct 293 ms 8436 KB Output is partially correct - 108510 call(s) of encode_bit()