제출 #573299

#제출 시각아이디문제언어결과실행 시간메모리
573299snowman앵무새 (IOI11_parrots)C++17
0 / 100
3 ms1080 KiB
#include<bits/stdc++.h>
#include "encoder.h"
#include "encoderlib.h"
using namespace std;  

void encode(int N, int M[]){
  int rs[N];
  for(int i = 0; i < N; i++){
    string a = "", b = "";
    int x = M[i];
    if(x == 0){
      a += '0';
    }
    while(x > 0){
      a += char('0' + x % 2);
      x /= 2;
    }
    int q = i;
    if(q == 0){
      b += '0';
    }
    while(q > 0){
      b += char('0' + q % 2);
      q /= 2;
    }
    for(int j = 8; j < 8 + b.size(); j++){
      a[j] = b[j - 8];
    }
    int ans = 0;
    for(int j = 0; j < 14; j++){
      if(a[j] == 1){
        ans += 1 << j;
      }
    }
    rs[i] = ans;
  }
  for(int i = 0; i < N; i++){
    send(rs[i]);
  }
}
#include "decoder.h"
#include "decoderlib.h"
#include<bits/stdc++.h>
using namespace std;

void decode(int N, int L, int X[])
{
  int rs[N];
  for(int i = 0; i < N ; i++){
    int x = X[i];
    string a = "", b= "", ab ="";
    while(x > 0){
      ab += char('0' + x % 2);
      x /= 2;
    }
    for(int j = 0; j < 8; j++){
      a += ab[j];
    }
    for(int j = 8; j < ab.size(); j++){
      b += ab[j];
    }
    int pos = 0, num = 0;
    for(int j = 0; j < a.size(); j++){
      if(a[j] == 1){
        num += 1 << j;
      }
    }
    for(int j = 0; j < b.size(); j++){
      if(b[j] == 1){
        pos += 1 << j;
      }
    }
    rs[pos] = num;
  }
  for(int i = 0; i < N; i++){
    output(rs[i]);
  }
}

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

encoder.cpp: In function 'void encode(int, int*)':
encoder.cpp:26:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |     for(int j = 8; j < 8 + b.size(); j++){
      |                    ~~^~~~~~~~~~~~~~

decoder.cpp: In function 'void decode(int, int, int*)':
decoder.cpp:19:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   19 |     for(int j = 8; j < ab.size(); j++){
      |                    ~~^~~~~~~~~~~
decoder.cpp:23:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   23 |     for(int j = 0; j < a.size(); j++){
      |                    ~~^~~~~~~~~~
decoder.cpp:28:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |     for(int j = 0; j < b.size(); j++){
      |                    ~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...