제출 #224546

#제출 시각아이디문제언어결과실행 시간메모리
224546jhnah917Saveit (IOI10_saveit)C++14
100 / 100
246 ms11888 KiB
#include "grader.h" #include "encoder.h" #include <bits/stdc++.h> using namespace std; int dst[44][1010]; vector<int> g[1010]; int par[1010]; int vis[1010]; void dfs(int v = 1){ vis[v] = 1; for(auto i : g[v]) if(!vis[i]){ par[i] = v; dfs(i); } } void bfs(int st){ dst[st][st] = 0; queue<int> q; q.push(st); while(q.size()){ int now = q.front(); q.pop(); for(auto nxt : g[now]) if(dst[st][nxt] == -1){ dst[st][nxt] = dst[st][now] + 1; q.push(nxt); } } } void encode(int N, int H, int M, int *v1, int *v2){ int n = N, m = M, h = H; for(int i=0; i<m; i++){ int s = v1[i] + 1, e = v2[i] + 1; g[s].push_back(e); g[e].push_back(s); } dfs(); for(int i=2; i<=n; i++){ for(int k=0; k<10; k++) encode_bit(!!(par[i] & (1 << k))); } memset(dst, -1, sizeof dst); for(int i=1; i<=h; i++) bfs(i); for(int i=1; i<=h; i++) for(int j=2; j<=n; j+=5){ int t = 0; for(int k=0; k<5; k++){ int now = dst[i][j+k] - dst[i][par[j+k]] + 1; if(j + k > n) now = 0; t = t * 3 + now; } for(int k=0; k<8; k++) encode_bit(!!(t & (1 << k))); } } //g++ grader.h grader.cpp encoder.h encoder.cpp decoder.h decoder.cpp -o main -std=c++14
#include "grader.h" #include "decoder.h" #include <bits/stdc++.h> using namespace std; /* dst[i][j] - dst[i][par[j]] 1 : 0 -1 : 11 0 : 10 */ int p[1010]; int mm[44][1010]; int chk[1010]; int ans[44][1010]; void go(int hh, int v){ if(v == 1) return; if(!chk[p[v]]) go(hh, p[v]); ans[hh][v] = ans[hh][p[v]] + mm[hh][v]; chk[v] = 1; } void decode(int N, int H) { int n = N, h = H; for(int i=2; i<=n; i++){ for(int j=0; j<10; j++) p[i] += (decode_bit() << j); } for(int i=1; i<=h; i++) for(int j=2; j<=n; j+=5){ int ret = 0; for(int k=0; k<8; k++) ret += (decode_bit() << k); for(int k=4; k>=0; k--){ mm[i][j+k] = ret % 3 - 1; ret /= 3; } } for(int i=1; i<=h; i++){ memset(chk, 0, sizeof chk); chk[1] = 1; for(int j=2; j<=n; j++) go(i, j); } for(int i=1; i<=h; i++) for(int j=1; j<=n; j++) hops(i-1, j-1, ans[i][j] - ans[i][i]); } //g++ grader.h grader.cpp encoder.h encoder.cpp decoder.h decoder.cpp -o main -std=c++14
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...