Submission #763660

# Submission time Handle Problem Language Result Execution time Memory
763660 2023-06-22T15:12:53 Z lukameladze Saveit (IOI10_saveit) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
#include "grader.h"
#include "encoder.h"
#define f first
#define s second
#define pb push_back
#define pii pair <int, int>
using namespace std;
const int N = 1005;
int n,k,m,dist[N][N],par[N];
vector <int> v[N];
void bfs(int x, int ty) {
    for (int i = 0; i < n; i++) {
        dist[x][i] = -1;
    }
    dist[x][x] = 0; queue <int> q; q.push(x);
    while (!q.empty()) {
        int y = q.front();
        q.pop();
        for (int to : v[y]) {
            if (dist[x][to] == -1) {
                if (ty == 1) {
                    par[to] = y; // mst[y].pb(to);
                }
                dist[x][to] = dist[x][y] + 1;
                q.push(to);
            }
        }
    }
}
void encode(int nv, int nh, int ne, int *v1, int *v2){
    n = nv;  k = nh; m = ne;
    for (int i = 0; i < m; i++) {
        int a = v1[i], b = v2[i];
        v[a].pb(b); v[b].pb(a);
    }
    for (int i = 0; i < k; i++) {
        bfs(i, 0);
    }
    bfs(0, 1);
    for (int i = 1; i < n; i++) {
        for (int j = 0; j < 10; j++) { // par[i]
            if (par[i]&(1<<j)) encode_bit(1);
            else encode_bit(0);
        }
    }
    for (int i = 0; i < k; i++) {
        for (int j = 0; j < 10; j++) {
            if ((1<<j)&dist[i][0]) encode_bit(1);
            else encode_bit(0);
        }
        for (int j = 1; j < n; j+=5) { // 00, 01, 10 ---> 0, 1, 2 
            int cur_sum = 0;
            for (int z = j; z < j + 5; z++) {
                int vl = 0;
                if (dist[i][z] == dist[i][par[z]] - 1 || z >= n) vl = 0;
                else if (dist[i][z] == dist[i][par[z]]) vl = 1;
                else if (dist[i][z] == dist[i][par[z]] + 1) vl = 2;
                else assert(false);
                cur_sum = cur_sum * 3 + vl;
            }

            for (int z = 0; z < 8; z++) {
                if ((1<<z)&cur_sum) encode_bit(1);
                else encode_bit(0);
            }
        }
    }
}
#include "grader.h"
#include "decoder.h"
#include <bits/stdc++.h>
using namespace std;
const int MX = 1000 + 5;
int diff[MX];
vector <int> g[MX];
void dfs(int a, int p) {
    if (p != -1) diff[a] += diff[p];
    for (int to : g[a]) {
        if (to == p) continue;
        dfs(to, a);
    }
}

void decode(int nv, int nh) {
    int n = nv, k = nh;
    for (int i = 1; i < n; i++) {
        int cur_par = 0;
        for (int j = 0; j < 10; j++) {
            int x = decode_bit();
            if (x) cur_par += (1<<j);
        }
        g[cur_par].pb(i);
    }
    for (int i = 0; i < k; i++) {
        int cur_val = 0;
        for (int j = 0; j < 10; j++) {
            int x = decode_bit();
            if (x) cur_val += (1<<j);
        }
        diff[0] = cur_val;
        for (int j = 1; j < n; j+=5) {
            int cur_sum = 0;
            for (int z = 0; z < 8; z++) {
                int x = decode_bit();
                if(x == 1) cur_sum += (1<<z);
            }
            for (int ve = j + 4; ve >= j; ve--) {
                if (cur_sum % 3 == 0) diff[ve] = -1;
                else if (cur_sum % 3 == 1) diff[ve] = 0;
                else if (cur_sum % 3 == 2) diff[ve] = 1;
                cur_sum /= 3;
            }
        }
        dfs(0, -1);
        for (int j = 0; j < n; j++) {
            hops(i, j, diff[j]);
        }
    }
}

Compilation message

decoder.cpp: In function 'void decode(int, int)':
decoder.cpp:24:20: error: 'class std::vector<int>' has no member named 'pb'
   24 |         g[cur_par].pb(i);
      |                    ^~