답안 #565030

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
565030 2022-05-20T07:57:53 Z almothana05 저장 (Saveit) (IOI10_saveit) C++14
컴파일 오류
0 ms 0 KB
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;
}
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:2:1: error: 'string' does not name a type
    2 | string bi(int x){
      | ^~~~~~
encoder.cpp: In function 'void encode(int, int, int, int*, int*)':
encoder.cpp:19:4: error: 'string' was not declared in this scope
   19 |    string s;
      |    ^~~~~~
encoder.cpp:44:7: error: 's' was not declared in this scope
   44 |       s = bi(gr[i][j]);
      |       ^
encoder.cpp:44:11: error: 'bi' was not declared in this scope; did you mean 'i'?
   44 |       s = bi(gr[i][j]);
      |           ^~
      |           i
encoder.cpp:46:9: error: 'encode_bit' was not declared in this scope; did you mean 'encode'?
   46 |         encode_bit(s[k] - '0');
      |         ^~~~~~~~~~
      |         encode

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