답안 #578008

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
578008 2022-06-15T18:23:04 Z 2fat2code 저장 (Saveit) (IOI10_saveit) C++17
0 / 100
260 ms 15356 KB
#include "grader.h"
#include "encoder.h"
#include <bits/stdc++.h>

using namespace std;

const int nmax = 1005;
const int hubs = 36;

int nn, hub, dist[hubs][nmax], par[nmax];
vector<int>nod[nmax];

bitset<nmax>viz;

void construct(){
    queue<int>q;
    viz.reset();
    q.push(0);
    viz[0] = 1;
    while(q.size()){
        auto it = q.front();
        q.pop();
        for(auto it1 : nod[it]){
            if(!viz[it1]){
                viz[it1] = 1;
                par[it1] = it;
                q.push(it1);
            }
        }
    }
    for(int i=1;i<nn;i++){
        for(int j=0;j<=9;j++){
            if(par[i] & (1 << j)) encode_bit(1);
            else encode_bit(0);
        }
    }
    for(int i=1;i<nn;i++){
        for(int j=0;j<hub;j+=3){
            int curr = 0;
            if(dist[j][i] == dist[j][par[i]]){
                 curr += 1;
            }
            else if(dist[j][i] > dist[j][par[i]]){
                 curr += 2;
            }
            curr *= 3;
            if(j + 1 <= hub - 1){
                if(dist[j+1][i] == dist[j+1][par[i]]){
                    curr += 1;
                }
                else if(dist[j+1][i] > dist[j+1][par[i]]){
                    curr += 2;
                }
            }
            curr *= 3;
            if(j + 2 <= hub - 1){
                if(dist[j+2][i] == dist[j+2][par[i]]){
                    curr += 1;
                }
                else if(dist[j+2][i] > dist[j+2][par[i]]){
                    curr += 2;
                }
            }
            for(int j=0;j<5;j++){
                encode_bit(curr % 2);
                curr /= 2;
            }
        }
    }
}

void encode(int n, int h, int m, int v1[], int v2[]){
    nn = n; hub = h;
    for(int i=0;i<m;i++){
        nod[v1[i]].push_back(v2[i]);
        nod[v2[i]].push_back(v1[i]);
    }
    for(int i=0;i<h;i++){
        queue<int>q;
        viz.reset();
        q.push(i);
        viz[i] = 1;
        while(q.size()){
            auto it = q.front();
            q.pop();
            for(auto it1 : nod[it]){
                if(!viz[it1]){
                    dist[i][it1] = dist[i][it] + 1;
                    viz[it1] = 1;
                    q.push(it1);
                }
            }
        }
    }
    construct();
}
#include "grader.h"
#include "decoder.h"
#include <bits/stdc++.h>
#define all(s) s.begin(), s.end()
#define fr first
#define sc second
using namespace std;

const int nmax = 1005;
const int hubs = 36;

int p[nmax], dust[hubs][nmax];
vector <int> nid[nmax];
bitset <nmax> vuz;
vector <int> bits[nmax];

void dfs(int s){
    vuz[s] = 1;
    for(auto it : nid[s]){
        if(!vuz[it]){
            dust[0][it] = dust[0][s] + 1;
            dfs(it);
        }
    }
}

void decode(int n, int h) {
    for(int i=1;i<n;i++){
        for(int j=0;j<=9;j++){
            p[i] += decode_bit() * (1 << j);
        }
    }
    for(int i=1;i<n;i++){
        nid[p[i]].push_back(i);
    }
    for(int i=1;i<n;i++){
        for(int j=0;j<h;j+=3){
            bits[i].push_back(decode_bit());
            bits[i].push_back(decode_bit());
            bits[i].push_back(decode_bit());
            bits[i].push_back(decode_bit());
            bits[i].push_back(decode_bit());
        }
    }
    assert(false);
    dfs(0);
    for(int i=0;i<h;i++) dust[i][0] = dust[0][i];
    for(int i=0;i<n;i++){
        for(auto it : nid[i]){
            int curr = 0;
            for(int j=0;j<h;j+=3){
                int lol = bits[it][curr++] + 2*bits[it][curr++] + 4*bits[it][curr++] + 8*bits[it][curr++] + 16*bits[it][curr++];
                if(j + 2 < h){
                    int suka = lol % 3;
                    if(suka == 0){
                        dust[j+2][it] = dust[j+2][i] - 1;
                    }
                    else if(suka == 2){
                        dust[j+2][it] = dust[j+2][i] + 1;
                    }
                }
                lol /= 3;
                if(j + 1 < h){
                    int suka = lol % 3;
                    if(suka == 0){
                        dust[j+1][it] = dust[j+1][i] - 1;
                    }
                    else if(suka == 2){
                        dust[j+1][it] = dust[j+1][i] + 1;
                    }
                }
                lol /= 3;
                if(j < h){
                    int suka = lol % 3;
                    if(suka == 0){
                        dust[j][it] = dust[j][i] - 1;
                    }
                    else if(suka == 2){
                        dust[j][it] = dust[j][i] + 1;
                    }
                }
                lol /= 3;
            }
        }
    }
    for(int i=0;i<h;i++){
        for(int j=0;j<n;j++){
            hops(i, j, dust[i][j]);
        }
    }
}

Compilation message

decoder.cpp: In function 'void decode(int, int)':
decoder.cpp:52:103: warning: operation on 'curr' may be undefined [-Wsequence-point]
   52 |                 int lol = bits[it][curr++] + 2*bits[it][curr++] + 4*bits[it][curr++] + 8*bits[it][curr++] + 16*bits[it][curr++];
      |                                                                                                   ~~~~^~
decoder.cpp:52:103: warning: operation on 'curr' may be undefined [-Wsequence-point]
decoder.cpp:52:103: warning: operation on 'curr' may be undefined [-Wsequence-point]
decoder.cpp:52:103: warning: operation on 'curr' may be undefined [-Wsequence-point]
# 결과 실행 시간 메모리 Grader output
1 Runtime error 260 ms 15356 KB Execution killed with signal 6
2 Runtime error 7 ms 8828 KB Execution killed with signal 6
3 Runtime error 22 ms 10464 KB Execution killed with signal 6
4 Runtime error 9 ms 8828 KB Execution killed with signal 6
5 Runtime error 28 ms 10552 KB Execution killed with signal 6
6 Runtime error 36 ms 10664 KB Execution killed with signal 6
7 Runtime error 49 ms 10964 KB Execution killed with signal 6
8 Runtime error 25 ms 10492 KB Execution killed with signal 6
9 Runtime error 32 ms 10644 KB Execution killed with signal 6
10 Runtime error 26 ms 10632 KB Execution killed with signal 6
11 Runtime error 27 ms 10728 KB Execution killed with signal 6
12 Runtime error 23 ms 10596 KB Execution killed with signal 6
13 Runtime error 63 ms 11216 KB Execution killed with signal 6
14 Runtime error 24 ms 10548 KB Execution killed with signal 6
15 Runtime error 27 ms 10728 KB Execution killed with signal 6
16 Runtime error 53 ms 11060 KB Execution killed with signal 6
17 Runtime error 40 ms 11044 KB Execution killed with signal 6
18 Runtime error 48 ms 11276 KB Execution killed with signal 6
19 Runtime error 40 ms 10812 KB Execution killed with signal 6
20 Runtime error 64 ms 11492 KB Execution killed with signal 6
21 Runtime error 73 ms 11660 KB Execution killed with signal 6
22 Runtime error 54 ms 11204 KB Execution killed with signal 6
23 Runtime error 75 ms 11988 KB Execution killed with signal 6
# 결과 실행 시간 메모리 Grader output
1 Runtime error 260 ms 15356 KB Execution killed with signal 6
2 Runtime error 7 ms 8828 KB Execution killed with signal 6
3 Runtime error 22 ms 10464 KB Execution killed with signal 6
4 Runtime error 9 ms 8828 KB Execution killed with signal 6
5 Runtime error 28 ms 10552 KB Execution killed with signal 6
6 Runtime error 36 ms 10664 KB Execution killed with signal 6
7 Runtime error 49 ms 10964 KB Execution killed with signal 6
8 Runtime error 25 ms 10492 KB Execution killed with signal 6
9 Runtime error 32 ms 10644 KB Execution killed with signal 6
10 Runtime error 26 ms 10632 KB Execution killed with signal 6
11 Runtime error 27 ms 10728 KB Execution killed with signal 6
12 Runtime error 23 ms 10596 KB Execution killed with signal 6
13 Runtime error 63 ms 11216 KB Execution killed with signal 6
14 Runtime error 24 ms 10548 KB Execution killed with signal 6
15 Runtime error 27 ms 10728 KB Execution killed with signal 6
16 Runtime error 53 ms 11060 KB Execution killed with signal 6
17 Runtime error 40 ms 11044 KB Execution killed with signal 6
18 Runtime error 48 ms 11276 KB Execution killed with signal 6
19 Runtime error 40 ms 10812 KB Execution killed with signal 6
20 Runtime error 64 ms 11492 KB Execution killed with signal 6
21 Runtime error 73 ms 11660 KB Execution killed with signal 6
22 Runtime error 54 ms 11204 KB Execution killed with signal 6
23 Runtime error 75 ms 11988 KB Execution killed with signal 6
# 결과 실행 시간 메모리 Grader output
1 Runtime error 260 ms 15356 KB Execution killed with signal 6
2 Runtime error 7 ms 8828 KB Execution killed with signal 6
3 Runtime error 22 ms 10464 KB Execution killed with signal 6
4 Runtime error 9 ms 8828 KB Execution killed with signal 6
5 Runtime error 28 ms 10552 KB Execution killed with signal 6
6 Runtime error 36 ms 10664 KB Execution killed with signal 6
7 Runtime error 49 ms 10964 KB Execution killed with signal 6
8 Runtime error 25 ms 10492 KB Execution killed with signal 6
9 Runtime error 32 ms 10644 KB Execution killed with signal 6
10 Runtime error 26 ms 10632 KB Execution killed with signal 6
11 Runtime error 27 ms 10728 KB Execution killed with signal 6
12 Runtime error 23 ms 10596 KB Execution killed with signal 6
13 Runtime error 63 ms 11216 KB Execution killed with signal 6
14 Runtime error 24 ms 10548 KB Execution killed with signal 6
15 Runtime error 27 ms 10728 KB Execution killed with signal 6
16 Runtime error 53 ms 11060 KB Execution killed with signal 6
17 Runtime error 40 ms 11044 KB Execution killed with signal 6
18 Runtime error 48 ms 11276 KB Execution killed with signal 6
19 Runtime error 40 ms 10812 KB Execution killed with signal 6
20 Runtime error 64 ms 11492 KB Execution killed with signal 6
21 Runtime error 73 ms 11660 KB Execution killed with signal 6
22 Runtime error 54 ms 11204 KB Execution killed with signal 6
23 Runtime error 75 ms 11988 KB Execution killed with signal 6
# 결과 실행 시간 메모리 Grader output
1 Runtime error 260 ms 15356 KB Execution killed with signal 6
2 Runtime error 7 ms 8828 KB Execution killed with signal 6
3 Runtime error 22 ms 10464 KB Execution killed with signal 6
4 Runtime error 9 ms 8828 KB Execution killed with signal 6
5 Runtime error 28 ms 10552 KB Execution killed with signal 6
6 Runtime error 36 ms 10664 KB Execution killed with signal 6
7 Runtime error 49 ms 10964 KB Execution killed with signal 6
8 Runtime error 25 ms 10492 KB Execution killed with signal 6
9 Runtime error 32 ms 10644 KB Execution killed with signal 6
10 Runtime error 26 ms 10632 KB Execution killed with signal 6
11 Runtime error 27 ms 10728 KB Execution killed with signal 6
12 Runtime error 23 ms 10596 KB Execution killed with signal 6
13 Runtime error 63 ms 11216 KB Execution killed with signal 6
14 Runtime error 24 ms 10548 KB Execution killed with signal 6
15 Runtime error 27 ms 10728 KB Execution killed with signal 6
16 Runtime error 53 ms 11060 KB Execution killed with signal 6
17 Runtime error 40 ms 11044 KB Execution killed with signal 6
18 Runtime error 48 ms 11276 KB Execution killed with signal 6
19 Runtime error 40 ms 10812 KB Execution killed with signal 6
20 Runtime error 64 ms 11492 KB Execution killed with signal 6
21 Runtime error 73 ms 11660 KB Execution killed with signal 6
22 Runtime error 54 ms 11204 KB Execution killed with signal 6
23 Runtime error 75 ms 11988 KB Execution killed with signal 6