Submission #565032

# Submission time Handle Problem Language Result Execution time Memory
565032 2022-05-20T07:58:32 Z almothana05 Saveit (IOI10_saveit) C++14
Compilation error
0 ms 0 KB
#include<bits/stdc++.h>
using namespace std;
int gr[1001][1001];
string bi(int x){
  string cmp;
  while(x){
    if(x % 2 ==0){
      cmp += '0';
    }
    else{
      cmp += '1';
    }
    x /= 2;
  }
  while(cmp.size() < 10){
    cmp += '0';
  }
  return cmp;
}
void encode(int nv, int nh, int ne, int *v1, int *v2){
   string s;
  for(int i = 0 ; i < 1001 ; i++){
    for(int j = 0 ; j< 1001 ; j++){
      gr[i][j] = 3000;
    }
  }
  for(int i = 0 ; i < ne ; i++){
    gr[v1[i]][v2[i]] = 1;
    gr[v2[i]][v1[i]] = 1;
  }
  for(int k = 0 ; k < 1001 ; k++){
    for(int i = 0 ; i < 1001 ; i++ ){
      for(int j = 0 ; j < 1001 ; j++){
        if(i == j){
          gr[i][j] = 0;
          continue;
        }
        if(gr[i][j] > gr[i][k] + gr[k][j]){
          gr[i][j] = gr[i][k] + gr[k][j];
        }
      }
    }
  }
  for(int i = 0 ; i < nh ; i++){
    for(int j = 0 ; j < nv ; j++){
      s = bi(gr[i][j]);
      for(int k = 0 ; k < s.size() ; k++){
        encode_bit(s[k] - '0');
      }
    }
  }
  // encode_bit(1);
  // encode_bit(0);
  return;
}
#include<bits/stdc++.h>
using namespace std;
void decode(int nv, int nh) {
   int rechner = 0;
   for(int i = 0 ; i < nh ; i++){
      for(int j = 0 ; j < nv ; j++){
         rechner = 0;
         for(int k = 1; k < 1024 ; k *= 2){
            rechner += k *decode_bit();
         }
         hops(i , j , rechner);
      }
   }
   // hops(0,0,0);
   // hops(1,2,3);
}

Compilation message

encoder.cpp: In function 'void encode(int, int, int, int*, int*)':
encoder.cpp:47:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   47 |       for(int k = 0 ; k < s.size() ; k++){
      |                       ~~^~~~~~~~~~
encoder.cpp:48:9: error: 'encode_bit' was not declared in this scope; did you mean 'encode'?
   48 |         encode_bit(s[k] - '0');
      |         ^~~~~~~~~~
      |         encode

decoder.cpp: In function 'void decode(int, int)':
decoder.cpp:9:27: error: 'decode_bit' was not declared in this scope; did you mean 'decode'?
    9 |             rechner += k *decode_bit();
      |                           ^~~~~~~~~~
      |                           decode
decoder.cpp:11:10: error: 'hops' was not declared in this scope
   11 |          hops(i , j , rechner);
      |          ^~~~