Submission #564994

# Submission time Handle Problem Language Result Execution time Memory
564994 2022-05-20T07:22:57 Z RealSnake Saveit (IOI10_saveit) C++14
Compilation error
0 ms 0 KB
void encode(int n, int h, int p, int a[], int b[]) {
    vector<int> v[n];
    for(int i = 0; i < p; i++) {
        v[a[i]].push_back(b[i]);
        v[b[i]].push_back(a[i]);
    }
    int vis[n];
    for(int i = n - 1; i >= 0; i--) {
        for(int j = 0; j < n; j++)
            vis[j] = 1e9;
        set<pair<int, int>> s;
        s.insert({0, i});
        int y = i + 1;
        while(s.size()) {
            pair<int, int> p = *s.begin();
            s.erase(s.begin());
            int x = p.second;
            int d = p.first;
            if(d > vis[x])
                continue;
            if(vis[x] != d)
                y--;
            vis[x] = d;
            if(!y)
                break;
            for(int j : v[x]) {
                if(d + (j < h) < vis[j]) {
                    vis[j] = d + (j < h);
                    s.insert({d + (j < h), j});
                }
            }
        }
        for(int j = i; j >= 0; j--) {
            for(int bit = 0; bit < 10; bit++)
                encode_bit((vis[j] & (1 << bit)) > 0);
        }
    }
    return;
}
void decode(int n, int h) {
    for(int i = n - 1; i >= 0; i--) {
        for(int j = i; j >= 0; j--) {
            int d = 0;
            for(int bit = 0; bit < 10; bit++) {
                if(decode_bit())
                    d += (1 << bit);
            }
            if(j >= h)
                continue;
            hops(j, i, d);
            if(i < h && i != j)
                hops(i, j, d);
        }
    }
    return;
}

Compilation message

encoder.cpp: In function 'void encode(int, int, int, int*, int*)':
encoder.cpp:2:5: error: 'vector' was not declared in this scope
    2 |     vector<int> v[n];
      |     ^~~~~~
encoder.cpp:2:12: error: expected primary-expression before 'int'
    2 |     vector<int> v[n];
      |            ^~~
encoder.cpp:4:9: error: 'v' was not declared in this scope
    4 |         v[a[i]].push_back(b[i]);
      |         ^
encoder.cpp:11:9: error: 'set' was not declared in this scope
   11 |         set<pair<int, int>> s;
      |         ^~~
encoder.cpp:11:13: error: 'pair' was not declared in this scope
   11 |         set<pair<int, int>> s;
      |             ^~~~
encoder.cpp:11:18: error: expected primary-expression before 'int'
   11 |         set<pair<int, int>> s;
      |                  ^~~
encoder.cpp:12:9: error: 's' was not declared in this scope
   12 |         s.insert({0, i});
      |         ^
encoder.cpp:15:18: error: expected primary-expression before 'int'
   15 |             pair<int, int> p = *s.begin();
      |                  ^~~
encoder.cpp:17:23: error: request for member 'second' in 'p', which is of non-class type 'int'
   17 |             int x = p.second;
      |                       ^~~~~~
encoder.cpp:18:23: error: request for member 'first' in 'p', which is of non-class type 'int'
   18 |             int d = p.first;
      |                       ^~~~~
encoder.cpp:26:25: error: 'v' was not declared in this scope
   26 |             for(int j : v[x]) {
      |                         ^
encoder.cpp:35:17: error: 'encode_bit' was not declared in this scope; did you mean 'encode'?
   35 |                 encode_bit((vis[j] & (1 << bit)) > 0);
      |                 ^~~~~~~~~~
      |                 encode

decoder.cpp: In function 'void decode(int, int)':
decoder.cpp:6:20: error: 'decode_bit' was not declared in this scope; did you mean 'decode'?
    6 |                 if(decode_bit())
      |                    ^~~~~~~~~~
      |                    decode
decoder.cpp:11:13: error: 'hops' was not declared in this scope
   11 |             hops(j, i, d);
      |             ^~~~