Submission #476979

#TimeUsernameProblemLanguageResultExecution timeMemory
476979wiktoria_bazanSaveit (IOI10_saveit)C++14
Compilation error
0 ms0 KiB
#include "grader.h" #include "encoder.h" #include<iostream> #include<vector> #include<queue> using namespace std; typedef long long ll; int const N = 1e3 + 9; vector<int> G[N]; queue<int>Q; int warstwa[N]; int ojciec[N]; bool odw[N]; int d[N]; void bfs(int v) { odw[v] = 1; warstwa[v] = 0; Q.push(v); while (!Q.empty()) { int v = Q.front(); Q.pop(); for (int i = 0; i < G[v].size(); i++) { int sas = G[v][i]; if (odw[sas] == 0) { odw[sas] = 1; warstwa[sas] = warstwa[v] + 1; Q.push(sas); } } } } void dfs(int v, int o) { odw[v] = 0; ojciec[v] = o; d[v] = warstwa[v] - warstwa[o] + 1; for (int i = 0; i < G[v].size(); i++) { int sas = G[v][i]; if (odw[sas] == 1) { dfs(sas, v); } } } void ll_to_bits(ll a, int b) { int t = 0; while (a > 0) { encode_bit(a % 2); a /= 2; t++; } while (t < b) { encode_bit(0); t++; } } void koduj_drzewo(int nv) { for (int v = 0; v < nv; v++) { ll_to_bits(ojciec[v], 10); } } void odl(int nv) { ll a = 0, mn = 1; for (int v = 0; v < nv; v++) { a += mn * d[v]; mn *= 3; } ll_to_bits(a, 58); } void encode(int nv, int nh, int ne, int* v1, int* v2) { for (int i = 0; i < ne; i++) { G[v1[i]].push_back(v2[i]); G[v2[i]].push_back(v1[i]); } bfs(0); dfs(0, 0); koduj_drzewo(nv); odl(nv); for (int h = 1; h < nh; h++) { bfs(h); odl(nv); } return; }
#include "grader.h" #include "decoder.h" #include<iostream> #include<vector> int const N = 1e3 + 9; int O[N]; vector<int>G[N]; int odl[N]; int d[N]; bool odw[N]; bool ost = true; void policz(int v){ odw[v] = ost; d[v] = d[O[v]] + odl[v]; for(int i = 0; i < G[v].size(); i++){ int syn = G[v][i]; if(odw[syn] != ost){ policz(syn); } } } void fczytaj_ojcuf(int nv){ for(int v = 0; v < nv; v++){ int o = 0, mn = 1; for(int i = 0; i < 10; i++){ int bit = decode_bit(); o += mn * bit; mn <<= 1; } G[o].push_back(v); } } void odzyskaj(int a, int nv){ int t = 0; while(a > 0){ odl[t] = (a % 3) - 1; a /= 3; t++; } while(t < nv){ odl[t] = -1; t++; } } void wypisz(int nv, int h){ for(int v = 0; v < nv; v++){ hops(h, v, d[v]); } } void fczytaj_odl(int nh, int nv){ for(int h = 0; h < nh; h++){ int a = 0, mn = 1; for(int i = 0; i < 58; i++){ int bit = decode_bit(); a += mn * bit; mn <<= 1; } odzyskaj(a, nv); d[h] = 0; policz(h); ost = !ost; wypisz(nv, h); } } void decode(int nv, int nh) { fczytaj_ojcuf(nv); fczytaj_odl(nh); }

Compilation message (stderr)

encoder.cpp: In function 'void bfs(int)':
encoder.cpp:25:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |         for (int i = 0; i < G[v].size(); i++) {
      |                         ~~^~~~~~~~~~~~~
encoder.cpp: In function 'void dfs(int, int)':
encoder.cpp:40:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   40 |     for (int i = 0; i < G[v].size(); i++) {
      |                     ~~^~~~~~~~~~~~~

decoder.cpp:8:1: error: 'vector' does not name a type
    8 | vector<int>G[N];
      | ^~~~~~
decoder.cpp: In function 'void policz(int)':
decoder.cpp:18:22: error: 'G' was not declared in this scope
   18 |   for(int i = 0; i < G[v].size(); i++){
      |                      ^
decoder.cpp: In function 'void fczytaj_ojcuf(int)':
decoder.cpp:34:5: error: 'G' was not declared in this scope
   34 |     G[o].push_back(v);
      |     ^
decoder.cpp: In function 'void decode(int, int)':
decoder.cpp:76:17: error: too few arguments to function 'void fczytaj_odl(int, int)'
   76 |   fczytaj_odl(nh);
      |                 ^
decoder.cpp:57:6: note: declared here
   57 | void fczytaj_odl(int nh, int nv){
      |      ^~~~~~~~~~~