Submission #565158

# Submission time Handle Problem Language Result Execution time Memory
565158 2022-05-20T11:06:13 Z katwamiaw Saveit (IOI10_saveit) C++14
Compilation error
0 ms 0 KB
#include<bits/stdc++.h>
#define ll long long
#define no cout << "NO\n"
#define yes cout << "YES\n"
#define endl '\n'
#define pb push_back
using namespace std ;
//fflush(stdout) ;

const int MAX_N=1e3+5 ;
vector<int>v[MAX_N] ;
int des[1004][1004] ;

int dfs(int x, int p , int s){
    for(int i:v[x]){
        if(i!=p&&(des[s][i]==-1||des[s][i]>(des[s][x]+1))){
            des[s][i]=(des[s][x]+1) ;
            dfs(i,x,s) ;
        }
    }
}

void encode(int nv, int nh, int ne, int *v1, int *v2){
  encode_bit(1);
  encode_bit(0);
  for(int i=0 ; i<ne ; i++){
      v[v1[i]].push_back(v2[i]) ;
      v[v2[i]].push_back(v1[i]) ;
  }
  for(int i=0 ; i<nv ; i++){
      for(int j=0 ; j<nv ; j++){
          des[i][j]=-1 ;
          if(i==j) des[i][j]=0 ;
      }
      dfs(i,0,i) ;
  }
  for(int i=0 ; i<nv ; i++){
      for(int j=0 ; j<nh ; j++){
          while(des[i][j]--){
               encode_bit(1) ;
          }
           encode_bit(0);
      }
  }
}
void decode(int nv, int nh) {
   for(int i=0 ; i<nv ; i++){
       for(int j=0 ; j<nh ; j++){
           int x , r=0 ;
           x=decode_bit() ;
           while(x==1){
                r++ ;
                x=decode_bit()
           }
            hops(j,i,r);
       }
   }
}

Compilation message

encoder.cpp: In function 'int dfs(int, int, int)':
encoder.cpp:21:1: warning: no return statement in function returning non-void [-Wreturn-type]
   21 | }
      | ^
encoder.cpp: In function 'void encode(int, int, int, int*, int*)':
encoder.cpp:24:3: error: 'encode_bit' was not declared in this scope; did you mean 'encode'?
   24 |   encode_bit(1);
      |   ^~~~~~~~~~
      |   encode

decoder.cpp: In function 'void decode(int, int)':
decoder.cpp:5:14: error: 'decode_bit' was not declared in this scope; did you mean 'decode'?
    5 |            x=decode_bit() ;
      |              ^~~~~~~~~~
      |              decode
decoder.cpp:10:13: error: 'hops' was not declared in this scope
   10 |             hops(j,i,r);
      |             ^~~~