제출 #900298

#제출 시각아이디문제언어결과실행 시간메모리
900298ar88lo앵무새 (IOI11_parrots)C++14
컴파일 에러
0 ms0 KiB
#include "encoder.h" #include "encoderlib.h" #include <bits/stdc++.h> using namespace std; vector<int> tovec(int a){ vector<int> ret; for(int i = 0; i < 8; i++){ ret.push_back(a%2); a/=2; } return ret; } int b [] = {0,1, 2, 3}; void encode(int N, int M[]){ vector<int> v; for(int i = N-1; i >= 0; i--){ vector<int> temp = tovec(M[i]); for(auto t:temp){ v.push_back(t); } } reverse(v.begin(), v.end()); int ind = 0; int times = 0; for(int i = 0; i <v.size(); i+=2){ times+=v[i]*2+v[i+1]; } if(times > 6*N){ send(0); send(0); send(0); send(0); reverse(b, b+4); } for(int i = 0; i <v.size(); i+=2){ if(v[i] == 1 && v[i+1] == 1){ for(int j = 0; j < b[0]; j++){ send(ind); } } if(v[i] == 1 && v[i+1] == 0){ for(int j = 0; j < b[1]; j++){ send(ind); } } if(v[i] == 0 && v[i+1] == 1){ for(int j = 0; j < b[2]; j++){ send(ind); } } if(v[i] == 0 && v[i+1] == 0) { for(int j = 0; j < b[3]; j++){ send(ind); } } ind++; } }
#include "decoder.h" #include "decoderlib.h" #include <bits/stdc++.h> using namespace std; int vectoint(vector<int> a){ reverse(a.begin(), a.end()); int ret = 0; for(int i = 0; i < a.size(); i++){ ret += (a[i]<<i); } return ret; } int b[3] = {0,1,2,3}; void decode(int N, int L, int X[]){ int c[256]; memset(c, 0, sizeof c); for(int i = 0; i < L; i++){ c[X[i]]++; } if(c[0] >= 4){ c[0] -= 4; reverse(b, b+4); } vector<int> ans; for(int i = 0; i < N * 8; i++) ans.push_back(0); for(int i = 0; i < 256; i++){ if(c[i] == b[0]){ ans[i*2] = 0; ans[i*2 + 1] = 0; } else if(c[i] == b[1]){ ans[i*2] = 0; ans[i*2+1] = 1; } else if(c[i] == b[2]){ ans[i*2] = 1; ans[i*2+1] = 0; } else { ans[i*2] = 1; ans[i*2+1] = 0; } } vector<int> temp; for(int i = 0; i < ans.size(); i+=8){ temp.clear(); for(int j = i; j < i+8; j++){ temp.push_back(ans[j]); } output(vectoint(temp)); } }

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

encoder.cpp: In function 'void encode(int, int*)':
encoder.cpp:28:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |     for(int i = 0; i <v.size(); i+=2){
      |                    ~~^~~~~~~~~
encoder.cpp:35:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   35 |     for(int i = 0; i <v.size(); i+=2){
      |                    ~~^~~~~~~~~

decoder.cpp: In function 'int vectoint(std::vector<int>)':
decoder.cpp:9:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    9 |         for(int i = 0; i < a.size(); i++){
      |                        ~~^~~~~~~~~~
decoder.cpp: At global scope:
decoder.cpp:14:20: error: too many initializers for 'int [3]'
   14 | int b[3] = {0,1,2,3};
      |                    ^
decoder.cpp: In function 'void decode(int, int, int*)':
decoder.cpp:50:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   50 |     for(int i = 0; i < ans.size(); i+=8){
      |                    ~~^~~~~~~~~~~~