제출 #636119

#제출 시각아이디문제언어결과실행 시간메모리
636119Do_you_copy앵무새 (IOI11_parrots)C++17
98 / 100
9 ms1384 KiB
#include "encoder.h" #include "encoderlib.h" #include <bits/stdc++.h> #define pb push_back using namespace std; using pii = pair <int, int>; void encode(int N, int M[]) { vector <int> v = {0, 1, 2, 3}; vector <int> sex; vector <int> pos[4]; for (int i = 0; i < N; ++i){ vector <int> bit; int x = M[i]; for (int j = 0; j < 4; ++j){ bit.pb(x % 4); x /= 4; } reverse(bit.begin(), bit.end()); for (int j = 0; j < 4; ++j){ pos[bit[j]].pb(i * 4 + j); } } int cnt = 0; pii minn = {INT_MAX, 0}; int a[] = {pos[0].size(), pos[1].size(), pos[2].size(), pos[3].size()}; do{ ++cnt; minn = min(minn, {v[0] * a[0] + v[1] * a[1] + v[2] * a[2] + v[3] * a[3], cnt}); } while (next_permutation(v.begin(), v.end())); sort(v.begin(), v.end()); int cnt2 = 1; while (cnt2 != minn.second){ ++cnt2; next_permutation(v.begin(), v.end()); } for (int i = 0; i < 4; ++i) sex.pb(cnt2); for (int i = 0; i < 4; ++i){ for (int j: pos[i]){ for (int k = 0; k < v[i]; ++k) sex.pb(j); } } //cerr << v[0] << " " << v[1] << " " << v[2] << " " << v[3] << "\n"; //cerr << a[0] * v[0] << " " << a[1] * v[1] << " " << a[2] * v[2] << " " << a[3] * v[3] << "\n"; //cerr << N << " " << minn.first << "\n"; for (int i: sex) send(i); }
#include "decoder.h" #include "decoderlib.h" #include <bits/stdc++.h>; using namespace std; void decode(int N, int L, int X[]) { vector <int> bit(257, 0); vector <int> ans(65, 0); sort(X, X + L); vector <int> v{0, 1, 2, 3}; int cnt = 0; for (int i = 0; i < L - 3; ++i){ if (X[i] == X[i + 1] && X[i + 1] == X[i + 2] && X[i + 2] == X[i + 3]){ cnt = X[i]; X[i] = X[i + 1] = X[i + 2] = X[i + 3] = 300; break; } } int cnt2 = 1; while (cnt2 != cnt){ ++cnt2; next_permutation(v.begin(), v.end()); } int power[] = {1, 4, 16, 64}; for (int i = 0; i < L; ++i){ if (X[i] > 256) continue; ++bit[X[i]]; } vector <int> v1(4); v1[v[0]] = 0; v1[v[1]] = 1; v1[v[2]] = 2; v1[v[3]] = 3; v = v1; for (int i = 0; i < N * 4; ++i) bit[i] = v[bit[i]]; for (int i = 0; i < N; ++i){ ans[i] = bit[i * 4] * power[3] + bit[i * 4 + 1] * power[2] + bit[i * 4 + 2] * power[1] + bit[i * 4 + 3] * power[0]; } //ofstream out("test.out"); for (int i = 0; i < N; ++i){ //out << ans[i] << " "; output(ans[i]); } //out.close(); }

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

encoder.cpp: In function 'void encode(int, int*)':
encoder.cpp:28:27: warning: narrowing conversion of 'pos[0].std::vector<int>::size()' from 'std::vector<int>::size_type' {aka 'long unsigned int'} to 'int' [-Wnarrowing]
   28 |     int a[] = {pos[0].size(), pos[1].size(), pos[2].size(), pos[3].size()};
      |                ~~~~~~~~~~~^~
encoder.cpp:28:42: warning: narrowing conversion of 'pos[1].std::vector<int>::size()' from 'std::vector<int>::size_type' {aka 'long unsigned int'} to 'int' [-Wnarrowing]
   28 |     int a[] = {pos[0].size(), pos[1].size(), pos[2].size(), pos[3].size()};
      |                               ~~~~~~~~~~~^~
encoder.cpp:28:57: warning: narrowing conversion of 'pos[2].std::vector<int>::size()' from 'std::vector<int>::size_type' {aka 'long unsigned int'} to 'int' [-Wnarrowing]
   28 |     int a[] = {pos[0].size(), pos[1].size(), pos[2].size(), pos[3].size()};
      |                                              ~~~~~~~~~~~^~
encoder.cpp:28:72: warning: narrowing conversion of 'pos[3].std::vector<int>::size()' from 'std::vector<int>::size_type' {aka 'long unsigned int'} to 'int' [-Wnarrowing]
   28 |     int a[] = {pos[0].size(), pos[1].size(), pos[2].size(), pos[3].size()};
      |                                                             ~~~~~~~~~~~^~

decoder.cpp:3:25: warning: extra tokens at end of #include directive
    3 | #include <bits/stdc++.h>;
      |                         ^
#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...