Submission #577014

# Submission time Handle Problem Language Result Execution time Memory
577014 2022-06-13T21:55:44 Z 2fat2code Saveit (IOI10_saveit) C++17
25 / 100
325 ms 15340 KB
#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 time Memory Grader output
1 Correct 325 ms 15340 KB Output is partially correct - 720000 call(s) of encode_bit()
2 Correct 2 ms 4612 KB Output is correct - 300 call(s) of encode_bit()
3 Correct 109 ms 9956 KB Output is partially correct - 648000 call(s) of encode_bit()
4 Correct 2 ms 4604 KB Output is correct - 500 call(s) of encode_bit()
5 Correct 129 ms 10144 KB Output is partially correct - 648000 call(s) of encode_bit()
6 Correct 126 ms 10664 KB Output is partially correct - 720000 call(s) of encode_bit()
7 Correct 138 ms 11060 KB Output is partially correct - 720000 call(s) of encode_bit()
8 Correct 123 ms 10296 KB Output is partially correct - 691920 call(s) of encode_bit()
9 Correct 119 ms 10484 KB Output is partially correct - 720000 call(s) of encode_bit()
10 Correct 139 ms 10488 KB Output is partially correct - 720000 call(s) of encode_bit()
11 Correct 126 ms 10612 KB Output is partially correct - 720000 call(s) of encode_bit()
12 Correct 149 ms 10512 KB Output is partially correct - 720000 call(s) of encode_bit()
13 Correct 156 ms 11128 KB Output is partially correct - 720000 call(s) of encode_bit()
14 Correct 151 ms 10544 KB Output is partially correct - 720000 call(s) of encode_bit()
15 Correct 119 ms 10656 KB Output is partially correct - 720000 call(s) of encode_bit()
16 Correct 165 ms 11128 KB Output is partially correct - 720000 call(s) of encode_bit()
17 Correct 134 ms 10904 KB Output is partially correct - 720000 call(s) of encode_bit()
18 Correct 180 ms 11220 KB Output is partially correct - 720000 call(s) of encode_bit()
19 Correct 151 ms 10760 KB Output is partially correct - 720000 call(s) of encode_bit()
20 Correct 151 ms 11492 KB Output is partially correct - 720000 call(s) of encode_bit()
21 Correct 163 ms 11628 KB Output is partially correct - 720000 call(s) of encode_bit()
22 Correct 163 ms 11284 KB Output is partially correct - 720000 call(s) of encode_bit()
23 Correct 165 ms 12000 KB Output is partially correct - 720000 call(s) of encode_bit()
# Verdict Execution time Memory Grader output
1 Correct 325 ms 15340 KB Output is partially correct - 720000 call(s) of encode_bit()
2 Correct 2 ms 4612 KB Output is correct - 300 call(s) of encode_bit()
3 Correct 109 ms 9956 KB Output is partially correct - 648000 call(s) of encode_bit()
4 Correct 2 ms 4604 KB Output is correct - 500 call(s) of encode_bit()
5 Correct 129 ms 10144 KB Output is partially correct - 648000 call(s) of encode_bit()
6 Correct 126 ms 10664 KB Output is partially correct - 720000 call(s) of encode_bit()
7 Correct 138 ms 11060 KB Output is partially correct - 720000 call(s) of encode_bit()
8 Correct 123 ms 10296 KB Output is partially correct - 691920 call(s) of encode_bit()
9 Correct 119 ms 10484 KB Output is partially correct - 720000 call(s) of encode_bit()
10 Correct 139 ms 10488 KB Output is partially correct - 720000 call(s) of encode_bit()
11 Correct 126 ms 10612 KB Output is partially correct - 720000 call(s) of encode_bit()
12 Correct 149 ms 10512 KB Output is partially correct - 720000 call(s) of encode_bit()
13 Correct 156 ms 11128 KB Output is partially correct - 720000 call(s) of encode_bit()
14 Correct 151 ms 10544 KB Output is partially correct - 720000 call(s) of encode_bit()
15 Correct 119 ms 10656 KB Output is partially correct - 720000 call(s) of encode_bit()
16 Correct 165 ms 11128 KB Output is partially correct - 720000 call(s) of encode_bit()
17 Correct 134 ms 10904 KB Output is partially correct - 720000 call(s) of encode_bit()
18 Correct 180 ms 11220 KB Output is partially correct - 720000 call(s) of encode_bit()
19 Correct 151 ms 10760 KB Output is partially correct - 720000 call(s) of encode_bit()
20 Correct 151 ms 11492 KB Output is partially correct - 720000 call(s) of encode_bit()
21 Correct 163 ms 11628 KB Output is partially correct - 720000 call(s) of encode_bit()
22 Correct 163 ms 11284 KB Output is partially correct - 720000 call(s) of encode_bit()
23 Correct 165 ms 12000 KB Output is partially correct - 720000 call(s) of encode_bit()
# Verdict Execution time Memory Grader output
1 Correct 325 ms 15340 KB Output is partially correct - 720000 call(s) of encode_bit()
2 Correct 2 ms 4612 KB Output is correct - 300 call(s) of encode_bit()
3 Correct 109 ms 9956 KB Output is partially correct - 648000 call(s) of encode_bit()
4 Correct 2 ms 4604 KB Output is correct - 500 call(s) of encode_bit()
5 Correct 129 ms 10144 KB Output is partially correct - 648000 call(s) of encode_bit()
6 Correct 126 ms 10664 KB Output is partially correct - 720000 call(s) of encode_bit()
7 Correct 138 ms 11060 KB Output is partially correct - 720000 call(s) of encode_bit()
8 Correct 123 ms 10296 KB Output is partially correct - 691920 call(s) of encode_bit()
9 Correct 119 ms 10484 KB Output is partially correct - 720000 call(s) of encode_bit()
10 Correct 139 ms 10488 KB Output is partially correct - 720000 call(s) of encode_bit()
11 Correct 126 ms 10612 KB Output is partially correct - 720000 call(s) of encode_bit()
12 Correct 149 ms 10512 KB Output is partially correct - 720000 call(s) of encode_bit()
13 Correct 156 ms 11128 KB Output is partially correct - 720000 call(s) of encode_bit()
14 Correct 151 ms 10544 KB Output is partially correct - 720000 call(s) of encode_bit()
15 Correct 119 ms 10656 KB Output is partially correct - 720000 call(s) of encode_bit()
16 Correct 165 ms 11128 KB Output is partially correct - 720000 call(s) of encode_bit()
17 Correct 134 ms 10904 KB Output is partially correct - 720000 call(s) of encode_bit()
18 Correct 180 ms 11220 KB Output is partially correct - 720000 call(s) of encode_bit()
19 Correct 151 ms 10760 KB Output is partially correct - 720000 call(s) of encode_bit()
20 Correct 151 ms 11492 KB Output is partially correct - 720000 call(s) of encode_bit()
21 Correct 163 ms 11628 KB Output is partially correct - 720000 call(s) of encode_bit()
22 Correct 163 ms 11284 KB Output is partially correct - 720000 call(s) of encode_bit()
23 Correct 165 ms 12000 KB Output is partially correct - 720000 call(s) of encode_bit()
# Verdict Execution time Memory Grader output
1 Correct 325 ms 15340 KB Output is partially correct - 720000 call(s) of encode_bit()
2 Correct 2 ms 4612 KB Output is correct - 300 call(s) of encode_bit()
3 Correct 109 ms 9956 KB Output is partially correct - 648000 call(s) of encode_bit()
4 Correct 2 ms 4604 KB Output is correct - 500 call(s) of encode_bit()
5 Correct 129 ms 10144 KB Output is partially correct - 648000 call(s) of encode_bit()
6 Correct 126 ms 10664 KB Output is partially correct - 720000 call(s) of encode_bit()
7 Correct 138 ms 11060 KB Output is partially correct - 720000 call(s) of encode_bit()
8 Correct 123 ms 10296 KB Output is partially correct - 691920 call(s) of encode_bit()
9 Correct 119 ms 10484 KB Output is partially correct - 720000 call(s) of encode_bit()
10 Correct 139 ms 10488 KB Output is partially correct - 720000 call(s) of encode_bit()
11 Correct 126 ms 10612 KB Output is partially correct - 720000 call(s) of encode_bit()
12 Correct 149 ms 10512 KB Output is partially correct - 720000 call(s) of encode_bit()
13 Correct 156 ms 11128 KB Output is partially correct - 720000 call(s) of encode_bit()
14 Correct 151 ms 10544 KB Output is partially correct - 720000 call(s) of encode_bit()
15 Correct 119 ms 10656 KB Output is partially correct - 720000 call(s) of encode_bit()
16 Correct 165 ms 11128 KB Output is partially correct - 720000 call(s) of encode_bit()
17 Correct 134 ms 10904 KB Output is partially correct - 720000 call(s) of encode_bit()
18 Correct 180 ms 11220 KB Output is partially correct - 720000 call(s) of encode_bit()
19 Correct 151 ms 10760 KB Output is partially correct - 720000 call(s) of encode_bit()
20 Correct 151 ms 11492 KB Output is partially correct - 720000 call(s) of encode_bit()
21 Correct 163 ms 11628 KB Output is partially correct - 720000 call(s) of encode_bit()
22 Correct 163 ms 11284 KB Output is partially correct - 720000 call(s) of encode_bit()
23 Correct 165 ms 12000 KB Output is partially correct - 720000 call(s) of encode_bit()