Submission #1017045

# Submission time Handle Problem Language Result Execution time Memory
1017045 2024-07-08T19:13:20 Z MilosMilutinovic Saveit (IOI10_saveit) C++14
0 / 100
375 ms 262144 KB
#include "grader.h"
#include "encoder.h"
#include <bits/stdc++.h>

using namespace std;

void encode(int nv, int nh, int ne, int *v1, int *v2) {
  vector<vector<int>> g(nv);
  for (int i = 0; i < ne; i++) {
    g[v1[i]].push_back(v2[i]);
    g[v2[i]].push_back(v1[i]);
  }
  vector<int> par(nv, -1);
  vector<bool> was(nv);
  function<void(int, int)> Dfs = [&](int v, int pv) {
    par[v] = pv;
    was[v] = true;
    for (int u : g[v]) {
      if (was[u]) {
        continue;
      }
      Dfs(u, v);
    }
  }; 
  Dfs(0, 0);
  for (int v = 0; v < nv; v++) {
    for (int b = 0; b < 10; b++) {
      encode_bit(par[v] >> b & 1);
    }
  }
  for (int h = 0; h < nh; h++) {
    vector<int> dist(nv, -1);
    dist[h] = 0;
    vector<int> que(1, h);
    for (int b = 0; b < (int) que.size(); b++) {
      int i = que[b];
      for (int j : g[i]) {
        if (dist[j] == -1) {
          dist[j] = dist[i] + 1;
          que.push_back(j);
        }
      }
    }
    for (int v = 0; v < nv; v++) {
      if (v + 2 >= nv) {
        if (dist[v] == dist[par[v]]) {
          encode_bit(0);
          encode_bit(1);
        }
        if (dist[v] == dist[par[v]] + 1) {
          encode_bit(1);
          encode_bit(0);
        }
        if (dist[v] == dist[par[v]] - 1) {
          encode_bit(0);
          encode_bit(0);
        }
        continue;
      }
      int num = 0;
      for (int t = v; t < v + 3; t++) {
        num = num * 3 + (dist[par[t]] - dist[t] + 1);
      }
      for (int b = 0; b < 5; b++) {
        encode_bit(num >> b & 1);
      }
      v += 2;
    }
  }
  return;
}
#include "grader.h"
#include "decoder.h"
#include <bits/stdc++.h>

using namespace std;

void decode(int nv, int nh) {
  vector<int> par(nv);
  for (int v = 0; v < nv; v++) {
    for (int b = 0; b < 10; b++) {
      if (decode_bit()) {
        par[v] += (1 << b);
      }
    }
  }
  vector<vector<int>> ch(nv);
  for (int i = 1; i < nv; i++) {
    ch[par[i]].push_back(i);
  }
  for (int h = 0; h < nh; h++) {
    vector<int> d(nv);
    for (int v = 0; v < nv; v++) {
      if (v + 2 >= nv) {
        int t = 0;
        t += 2 * decode_bit();
        t += decode_bit();
        d[v] = t - 1;
        continue;
      }
      int num = 0;
      for (int b = 0; b < 5; b++) {
        if (decode_bit()) {
          num += (1 << b);
        }
      }
      for (int t = v + 2; t >= v; t--) {
        d[t] = (num % 3) - 1;
        num /= 3;
      }
      v += 2;
    }
    vector<int> dist(nv, -1);
    dist[h] = 0;
    vector<int> que(1, h);
    for (int b = 0; b < (int) que.size(); b++) {
      int i = que[b];
      for (int j : ch[i]) {
        if (dist[j] == -1) {
          dist[j] = dist[i] + d[j];
          que.push_back(j);
        }
      }
      if (dist[par[i]] == -1) {
        dist[par[i]] = dist[i] - d[i];
        que.push_back(par[i]);
      }
    }
    for (int v = 0; v < nv; v++) {
      hops(h, v, dist[v]);
    }
  }
}
# Verdict Execution time Memory Grader output
1 Runtime error 375 ms 262144 KB Execution killed with signal 9
2 Runtime error 198 ms 262144 KB Execution killed with signal 9
3 Incorrect 11 ms 11536 KB wrong parameter
4 Runtime error 212 ms 262144 KB Execution killed with signal 9
5 Runtime error 345 ms 262144 KB Execution killed with signal 9
6 Incorrect 12 ms 11524 KB wrong parameter
7 Runtime error 369 ms 262144 KB Execution killed with signal 9
8 Incorrect 13 ms 11260 KB wrong parameter
9 Incorrect 11 ms 11264 KB wrong parameter
10 Runtime error 250 ms 262144 KB Execution killed with signal 9
11 Incorrect 13 ms 11520 KB wrong parameter
12 Incorrect 13 ms 11356 KB wrong parameter
13 Runtime error 250 ms 262144 KB Execution killed with signal 9
14 Incorrect 16 ms 11268 KB wrong parameter
15 Runtime error 224 ms 262144 KB Execution killed with signal 9
16 Incorrect 25 ms 11756 KB wrong parameter
17 Runtime error 250 ms 262144 KB Execution killed with signal 9
18 Runtime error 251 ms 262144 KB Execution killed with signal 9
19 Runtime error 251 ms 262144 KB Execution killed with signal 9
20 Incorrect 37 ms 14312 KB wrong parameter
21 Runtime error 257 ms 262144 KB Execution killed with signal 9
22 Runtime error 237 ms 262144 KB Execution killed with signal 9
23 Incorrect 45 ms 14500 KB wrong parameter
# Verdict Execution time Memory Grader output
1 Runtime error 375 ms 262144 KB Execution killed with signal 9
2 Runtime error 198 ms 262144 KB Execution killed with signal 9
3 Incorrect 11 ms 11536 KB wrong parameter
4 Runtime error 212 ms 262144 KB Execution killed with signal 9
5 Runtime error 345 ms 262144 KB Execution killed with signal 9
6 Incorrect 12 ms 11524 KB wrong parameter
7 Runtime error 369 ms 262144 KB Execution killed with signal 9
8 Incorrect 13 ms 11260 KB wrong parameter
9 Incorrect 11 ms 11264 KB wrong parameter
10 Runtime error 250 ms 262144 KB Execution killed with signal 9
11 Incorrect 13 ms 11520 KB wrong parameter
12 Incorrect 13 ms 11356 KB wrong parameter
13 Runtime error 250 ms 262144 KB Execution killed with signal 9
14 Incorrect 16 ms 11268 KB wrong parameter
15 Runtime error 224 ms 262144 KB Execution killed with signal 9
16 Incorrect 25 ms 11756 KB wrong parameter
17 Runtime error 250 ms 262144 KB Execution killed with signal 9
18 Runtime error 251 ms 262144 KB Execution killed with signal 9
19 Runtime error 251 ms 262144 KB Execution killed with signal 9
20 Incorrect 37 ms 14312 KB wrong parameter
21 Runtime error 257 ms 262144 KB Execution killed with signal 9
22 Runtime error 237 ms 262144 KB Execution killed with signal 9
23 Incorrect 45 ms 14500 KB wrong parameter
# Verdict Execution time Memory Grader output
1 Runtime error 375 ms 262144 KB Execution killed with signal 9
2 Runtime error 198 ms 262144 KB Execution killed with signal 9
3 Incorrect 11 ms 11536 KB wrong parameter
4 Runtime error 212 ms 262144 KB Execution killed with signal 9
5 Runtime error 345 ms 262144 KB Execution killed with signal 9
6 Incorrect 12 ms 11524 KB wrong parameter
7 Runtime error 369 ms 262144 KB Execution killed with signal 9
8 Incorrect 13 ms 11260 KB wrong parameter
9 Incorrect 11 ms 11264 KB wrong parameter
10 Runtime error 250 ms 262144 KB Execution killed with signal 9
11 Incorrect 13 ms 11520 KB wrong parameter
12 Incorrect 13 ms 11356 KB wrong parameter
13 Runtime error 250 ms 262144 KB Execution killed with signal 9
14 Incorrect 16 ms 11268 KB wrong parameter
15 Runtime error 224 ms 262144 KB Execution killed with signal 9
16 Incorrect 25 ms 11756 KB wrong parameter
17 Runtime error 250 ms 262144 KB Execution killed with signal 9
18 Runtime error 251 ms 262144 KB Execution killed with signal 9
19 Runtime error 251 ms 262144 KB Execution killed with signal 9
20 Incorrect 37 ms 14312 KB wrong parameter
21 Runtime error 257 ms 262144 KB Execution killed with signal 9
22 Runtime error 237 ms 262144 KB Execution killed with signal 9
23 Incorrect 45 ms 14500 KB wrong parameter
# Verdict Execution time Memory Grader output
1 Runtime error 375 ms 262144 KB Execution killed with signal 9
2 Runtime error 198 ms 262144 KB Execution killed with signal 9
3 Incorrect 11 ms 11536 KB wrong parameter
4 Runtime error 212 ms 262144 KB Execution killed with signal 9
5 Runtime error 345 ms 262144 KB Execution killed with signal 9
6 Incorrect 12 ms 11524 KB wrong parameter
7 Runtime error 369 ms 262144 KB Execution killed with signal 9
8 Incorrect 13 ms 11260 KB wrong parameter
9 Incorrect 11 ms 11264 KB wrong parameter
10 Runtime error 250 ms 262144 KB Execution killed with signal 9
11 Incorrect 13 ms 11520 KB wrong parameter
12 Incorrect 13 ms 11356 KB wrong parameter
13 Runtime error 250 ms 262144 KB Execution killed with signal 9
14 Incorrect 16 ms 11268 KB wrong parameter
15 Runtime error 224 ms 262144 KB Execution killed with signal 9
16 Incorrect 25 ms 11756 KB wrong parameter
17 Runtime error 250 ms 262144 KB Execution killed with signal 9
18 Runtime error 251 ms 262144 KB Execution killed with signal 9
19 Runtime error 251 ms 262144 KB Execution killed with signal 9
20 Incorrect 37 ms 14312 KB wrong parameter
21 Runtime error 257 ms 262144 KB Execution killed with signal 9
22 Runtime error 237 ms 262144 KB Execution killed with signal 9
23 Incorrect 45 ms 14500 KB wrong parameter