제출 #1094954

#제출 시각아이디문제언어결과실행 시간메모리
1094954steveonalex앵무새 (IOI11_parrots)C++17
99 / 100
64 ms28864 KiB
#include <bits/stdc++.h> #include "encoder.h" #include "encoderlib.h" using namespace std; typedef long long ll; typedef unsigned long long ull; #define MASK(i) (1LL << (i)) #define GETBIT(mask, i) (((mask) >> (i)) & 1) #define ALL(v) (v).begin(), (v).end() #define block_of_code if(true) ll max(ll a, ll b){return (a > b) ? a : b;} ll min(ll a, ll b){return (a < b) ? a : b;} ll gcd(ll a, ll b){return __gcd(a, b);} ll lcm(ll a, ll b){return a / gcd(a, b) * b;} ll LASTBIT(ll mask){return (mask) & (-mask);} int pop_cnt(ll mask){return __builtin_popcountll(mask);} int ctz(ull mask){return __builtin_ctzll(mask);} int logOf(ull mask){return 63 - __builtin_clzll(mask);} mt19937_64 rng(chrono::high_resolution_clock::now().time_since_epoch().count()); ll rngesus(ll l, ll r){return l + (ull) rng() % (r - l + 1);} double rngesus_d(double l, double r){ double cur = rngesus(0, MASK(60) - 1); cur /= MASK(60) - 1; return l + cur * (r - l); } template <class T1, class T2> bool maximize(T1 &a, T2 b){ if (a < b) {a = b; return true;} return false; } template <class T1, class T2> bool minimize(T1 &a, T2 b){ if (a > b) {a = b; return true;} return false; } template <class T> void printArr(T container, string separator = " ", string finish = "\n", ostream &out = cout){ for(auto item: container) out << item << separator; out << finish; } template <class T> void remove_dup(vector<T> &a){ sort(ALL(a)); a.resize(unique(ALL(a)) - a.begin()); } vector<vector<int>> state; const int MA = 8, P = 11; void generate_state(){ if (state.size()) return; state.push_back({}); for(int i = 0; i < MA; ++i){ vector<vector<int>> cur; for(vector<int> j: state){ while(j.size() <= P){ cur.push_back(j); j.push_back(i); } } state = cur; } sort(ALL(state)); } void encode(int N, int M[]){ generate_state(); vector<int> a((N + 1) / 2); for(int i= 0; i< N; ++i){ a[i / 2] += M[i] * MASK((i % 2) * 8); } for(int i = 0; i < a.size(); ++i){ for(int j: state[a[i]]) send(j + MA * i); } }
#include <bits/stdc++.h> #include "decoder.h" #include "decoderlib.h" using namespace std; typedef long long ll; typedef unsigned long long ull; #define MASK(i) (1LL << (i)) #define GETBIT(mask, i) (((mask) >> (i)) & 1) #define ALL(v) (v).begin(), (v).end() #define block_of_code if(true) ll max(ll a, ll b){return (a > b) ? a : b;} ll min(ll a, ll b){return (a < b) ? a : b;} ll gcd(ll a, ll b){return __gcd(a, b);} ll lcm(ll a, ll b){return a / gcd(a, b) * b;} ll LASTBIT(ll mask){return (mask) & (-mask);} int pop_cnt(ll mask){return __builtin_popcountll(mask);} int ctz(ull mask){return __builtin_ctzll(mask);} int logOf(ull mask){return 63 - __builtin_clzll(mask);} mt19937_64 rng(chrono::high_resolution_clock::now().time_since_epoch().count()); ll rngesus(ll l, ll r){return l + (ull) rng() % (r - l + 1);} double rngesus_d(double l, double r){ double cur = rngesus(0, MASK(60) - 1); cur /= MASK(60) - 1; return l + cur * (r - l); } template <class T1, class T2> bool maximize(T1 &a, T2 b){ if (a < b) {a = b; return true;} return false; } template <class T1, class T2> bool minimize(T1 &a, T2 b){ if (a > b) {a = b; return true;} return false; } template <class T> void printArr(T container, string separator = " ", string finish = "\n", ostream &out = cout){ for(auto item: container) out << item << separator; out << finish; } template <class T> void remove_dup(vector<T> &a){ sort(ALL(a)); a.resize(unique(ALL(a)) - a.begin()); } vector<vector<int>> state; const int MA = 8, P = 11; void generate_state(){ if (state.size()) return; state.push_back({}); for(int i = 0; i < MA; ++i){ vector<vector<int>> cur; for(vector<int> j: state){ while(j.size() <= P){ cur.push_back(j); j.push_back(i); } } state = cur; } sort(ALL(state)); } void decode(int N, int L, int X[]){ generate_state(); vector<int> ans(N + 1); vector<vector<int>> cur((N + 1) / 2); for(int i = 0; i < L; ++i){ cur[X[i] / 8].push_back(X[i]); } for(int i = 0; i < cur.size(); ++i){ sort(ALL(cur[i])); for(int &j: cur[i]) j -= i * MA; int idx = lower_bound(ALL(state), cur[i]) - state.begin(); ans[i * 2] = idx % MASK(8); ans[i * 2 + 1] = idx / MASK(8); } while(ans.size() > N) ans.pop_back(); for(int i: ans) output(i); }

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

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

decoder.cpp: In function 'void decode(int, int, int*)':
decoder.cpp:84:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   84 |     for(int i = 0; i < cur.size(); ++i){
      |                    ~~^~~~~~~~~~~~
decoder.cpp:92:22: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   92 |     while(ans.size() > N) ans.pop_back();
      |           ~~~~~~~~~~~^~~
#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...