제출 #64412

#제출 시각아이디문제언어결과실행 시간메모리
64412alenam0161저장 (Saveit) (IOI10_saveit)C++17
0 / 100
366 ms12224 KiB
#include "grader.h" #include "encoder.h" #include <bits/stdc++.h> using namespace std; #define fr first #define sc second #define cout cerr const int N=1006,H=40,P3[6]={1,3,9,27,81,243}; vector<int> g[N],graph[N]; int pars[N],pr[H][N]; bool col[N]; queue<pair<int,int> > q; int dist[N][H]; void to_bit(int k){ for (int i=9;i>=0;i--){ if (k&(1<<i)){ encode_bit(1); } else{ encode_bit(0); } } } void dfs(int v,int p=-1){ col[v]=true; for (int i=0;i<g[v].size();i++){ int to=g[v][i]; if (!col[to]) dfs(to,v); } pars[v]=p; } void dfshub(int v,int hub,int p=-1){ for (int i=0;i<graph[v].size();i++){ int to=graph[v][i]; if (to!=p)dfshub(to,hub,v); } if (p!=-1) pr[hub][v]=p; } void encode(int n, int h, int m, int *a, int *b){ for (int i=0;i<m;i++){ g[a[i]].push_back(b[i]); g[b[i]].push_back(a[i]); } dfs(0); for (int i=0;i<h;i++){ for (int j=0;j<n;j++)col[j]=false; q.push({i,0}); col[i]=true; while(!q.empty()){ int v=q.front().fr,len=q.front().sc; q.pop(); dist[v][i]=len; for (int j=0;j<g[v].size();j++){ int to=g[v][j]; if (!col[to]){ q.push({to,len+1}); col[to]=true; } } } } for (int i=1;i<n;i++){ to_bit(pars[i]); graph[i].push_back(pars[i]); graph[pars[i]].push_back(i); } for (int i=0;i<h;i++)dfshub(i,i); for (int i=0;i<n;i++){ int ans=0; for (int j=0;j<36;j++){ ans+=P3[(6-((j+1)%6))%6]*(dist[i][j]-dist[pr[j][i]][j]+1); if ((j+1)%6==0){ to_bit(ans); ans=0; } } } }
#include "grader.h" #include "decoder.h" #include <bits/stdc++.h> using namespace std; #define fr first #define sc second #define cout cerr const int N=1006,H=40,P3[6]={1,3,9,27,81,243}; vector<int> gr[N]; int tarb[N][H]; int to_dec(){ int ans=0; for (int i=9;i>=0;i--){ ans+=(1<<i)*decode_bit(); } return ans; } void to_tr(int k,int arr[]){ for (int i=5;i>=0;i--){ arr[5-i]=k/P3[i]; k%=P3[i]; } } int dfsdec(int v,int ans,int hub,int par=-1){ for (int i=0;i<gr[v].size();i++){ int to=gr[v][i]; if (to!=par) dfsdec(to,ans+tarb[to][hub]-1,hub,v); } hops(hub,v,ans); } void decode(int n, int h) { for (int i=1;i<n;i++){ int p=to_dec(); gr[p].push_back(i); gr[i].push_back(p); } for (int i=0;i<n;i++){ for (int j=0;j<6;j++){ to_tr(to_dec(),tarb[i]+(j*6)); } } for (int i=0;i<h;i++){ dfsdec(i,0,i); } }

컴파일 시 표준 에러 (stderr) 메시지

encoder.cpp: In function 'void dfs(int, int)':
encoder.cpp:30:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i=0;i<g[v].size();i++){
                  ~^~~~~~~~~~~~
encoder.cpp: In function 'void dfshub(int, int, int)':
encoder.cpp:38:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i=0;i<graph[v].size();i++){
                  ~^~~~~~~~~~~~~~~~
encoder.cpp: In function 'void encode(int, int, int, int*, int*)':
encoder.cpp:60:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             for (int j=0;j<g[v].size();j++){
                          ~^~~~~~~~~~~~

decoder.cpp: In function 'int dfsdec(int, int, int, int)':
decoder.cpp:30:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i=0;i<gr[v].size();i++){
                  ~^~~~~~~~~~~~~
decoder.cpp:36:1: warning: no return statement in function returning non-void [-Wreturn-type]
 }
 ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...