Submission #676726

# Submission time Handle Problem Language Result Execution time Memory
676726 2022-12-31T20:50:55 Z nvujica Saveit (IOI10_saveit) C++14
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
#include "grader.h"
#include "encoder.h"
#define ll long long

using namespace std;

const int maxn = 1005, maxh = 40;

int dist[maxh][maxn];
queue <int> q;
vector <int> v[maxn];
int bio[maxn];
int par[maxn];

void rek(int x, int p){
	bio[x] = 1;
	par[x] = p;
	
	for(int i = 0; i < v[x].size(); i++){
		int x2 = v[x][i];
		
		if(bio[x2]) continue;
		
		rek(x2, x);
	}
}

void encode(int n, int h, int p, int *a, int *b){
	memset(dist, -1, sizeof dist);
	
	for(int i = 0; i < p; i++){
		v[a[i]].push_back(b[i]);
		v[b[i]].push_back(a[i]);
	}
	
	for(int i = 0; i < h; i++){
		dist[i][i] = 0;
		q.push(i);
		
		while(!q.empty()){
			int x = q.front();
			q.pop();
			
			for(int j = 0; j < v[x].size(); j++){
				int x2 = v[x][j];
				
				if(dist[i][x2] == -1){
					dist[i][x2] = dist[i][x] + 1;
					q.push(x2);
				}
			}
		}
	}
	
	for(int i = 0; i < h; i++){
		for(int j = 9; j >= 0; j--){
			if(dist[0][i] & (1 << j)) encode_bit(1);
			else encode_bit(0);
		}
	}
	
	rek(0, -1);
	
	for(int i = 1; i < n; i++){
		ll b3 = 0;
		
		for(int j = 0; j < h; j++){
			b3 *= 3;
			
			if(dist[j][i] - dist[j][par[i]] == 1) b3 += 1;
			else if(dist[j][i] - dist[j][par[i]] == -1) b3 += 2; 
		}
		
		for(int j = 9; j >= 0; j--){
			if(par[i] & (1 << j)) encode_bit(1);
			else encode_bit(0);
		}
		
		for(int j = 57; j >= 0; j--){
			if(b3 & (1LL << j)) encode_bit(1);
			else encode_bit(0);
		}
	}
}
#include <bits/stdc++.h>
#define ll long long
#include "grader.h"
#include "decoder.h"

using namespace std;

const int maxn = 1005, maxh = 40;

int dist[maxh][maxn];
int d[maxn][maxh];
vector <int> v;

void rek(int x){
	for(int i = 0; i < v[x].size(); i++){
		int x2 = v[x][i];
		
		for(int j = 0; j < h; j++){
			dist[j][x2] = dist[j][x] + d[x2][j];
		}
	}
}

void decode(int n, int h){
	for(int i = 0; i < h; i++){
		for(int j = 0; j < 10; j++){
			dist[0][i] *= 2;
			dist[0][i] += decode_bit();
		}
	}
	
	for(int i = 1; i < n; i++){
		int p = 0;
		
		for(int j = 0; j < 10; j++){
			p *= 2;
			p += decode_bit();
		}
		
		v[p].push_back(i);
		
		ll b3 = 0;
		
		for(int j = 0; j < 58; j++){
			b3 *= 2;
			b3 += decode_bit();
		}
		
		for(int j = 0; j < h; j++){
			int x = b3 % 3;
			
			if(x == 1) d[i][j] = 1;
			if(x == 2) d[i][j] = -1;
			
			b3 /= 3;
		}
	}
	
	for(int i = 0; i < h; i++){
		for(int j = 0; j < n; j++){
			hops(i, j, dist[i][j]);
		}
	}
}

Compilation message

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

decoder.cpp: In function 'void rek(int)':
decoder.cpp:15:26: error: request for member 'size' in 'v.std::vector<int>::operator[](((std::vector<int>::size_type)x))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}
   15 |  for(int i = 0; i < v[x].size(); i++){
      |                          ^~~~
decoder.cpp:16:16: error: invalid types '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type {aka int}[int]' for array subscript
   16 |   int x2 = v[x][i];
      |                ^
decoder.cpp:18:22: error: 'h' was not declared in this scope
   18 |   for(int j = 0; j < h; j++){
      |                      ^
decoder.cpp: In function 'void decode(int, int)':
decoder.cpp:40:8: error: request for member 'push_back' in 'v.std::vector<int>::operator[](((std::vector<int>::size_type)p))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}
   40 |   v[p].push_back(i);
      |        ^~~~~~~~~