제출 #577014

#제출 시각아이디문제언어결과실행 시간메모리
5770142fat2code저장 (Saveit) (IOI10_saveit)C++17
25 / 100
325 ms15340 KiB
#include "grader.h"
#include "encoder.h"
#include <bits/stdc++.h>

using namespace std;

const int nmax = 1005;

int par[nmax];
vector<int>nod[nmax], nod1[nmax];
vector<int>euler;
bitset<nmax>viz;

void dfs(int s){
    viz[s] = 1;
    euler.push_back(s);
    for(auto it : nod1[s]){
        if(!viz[it]){
            dfs(it);
        }
    }
    euler.push_back(s);
}

void encode(int nv, int nh, int ne, int v1[], int v2[]){
    for(int i=0;i<ne;i++){
        nod[v1[i]].push_back(v2[i]);
        nod[v2[i]].push_back(v1[i]);
    }
    for(int i=0;i<nh;i++){
        euler.clear();
        viz.reset();
        for(int i=0;i<nv;i++) nod1[i].clear();
        queue<int>q;
        q.push(i);
        viz[i] = 1;
        while(q.size()){
            auto it = q.front();
            q.pop();
            for(auto it1 : nod[it]){
                if(!viz[it1]){
                    viz[it1] = 1;
                    nod1[it].push_back(it1);
                    q.push(it1);
                }
            }
        }
        viz.reset();
        dfs(i);
        for(auto it : euler){
            for(int i=0;i<=9;i++){
                if(it & (1 << i)) encode_bit(1);
                else encode_bit(0);
            }
        }
    }
    return;
}
#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;

int nn, hh, dist[nmax], first[nmax], last[nmax];
vector<int>oiler;
vector<pair<int,pair<int,int>>>ans;

void decode(int nv, int nh) {
   nn = nv, hh = nh;
   for(int i=0;i<hh;i++){
        oiler.clear();
        for(int j=1;j<=2*nn;j++){

            int curr = 0;
            for(int t=0;t<=9;t++){
                curr += decode_bit() * (1 << t);
            }
            oiler.push_back(curr);
        }
        vector<int>root;
        for(int j=0;j<nn;j++) dist[j] = 0, first[j] = 0, last[j] = 0;
        for(int j=0;j<(int)oiler.size();j++){
            if(!first[oiler[j]]) first[oiler[j]] = (j + 1);
            else last[oiler[j]] = (j + 1);
        }
        for(int j=0;j<(int)oiler.size();j++){
            if(first[oiler[j]] == (j + 1)){
                if(j != 0) dist[oiler[j]] = dist[root.back()] + 1;
                root.push_back(oiler[j]);
            }
            else{
                root.pop_back();
            }
        }
        for(int j=0;j<nv;j++)hops(i, j, dist[j]);
    }
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...