Submission #758546

#TimeUsernameProblemLanguageResultExecution timeMemory
758546CpDarkParrots (IOI11_parrots)C++17
0 / 100
5 ms1072 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef vector<int> vi; typedef vector<vi> vvi; const int SIZE = 8; const int ORDERBITS = 5; int pows2[] = { 1,2,4,8,16,32,64,128 }; void send(int a); void output(int b); inline int readid(int num) { for (int i = SIZE - 1; i >= ORDERBITS; i--) { if (num - pows2[i] >= 0) { num -= pows2[i]; } } return num; } inline int readBit(int num) { int ans = 0; for (int i = SIZE - 1; i >= ORDERBITS; i--) { if (num - pows2[i] >= 0) { num -= pows2[i]; ans += pows2[i - ORDERBITS]; } } return ans; } inline int getShift(int num) { int ans = 0; for (int i = SIZE - ORDERBITS - 1;i >= 0;i--) { if (num - pows2[i] >= 0) { ans += pows2[i + ORDERBITS]; num -= pows2[i]; } } return ans; } inline void sendForNum(int num, int index) { for (int i = SIZE - 1;i >= 0;i--) { if (num - pows2[i] >= 0) { num -= pows2[i]; int curr = index + getShift(i); send(curr); } } } void encode(int N, int M[]) { vi arr(N); for (int i = 0;i < N;i++) { arr[i] = M[i]; } sort(arr.begin(), arr.end()); for (int i = 0;i < N;i++) { sendForNum(arr[i], i); } }
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef vector<int> vi; typedef vector<vi> vvi; const int SIZE = 8; const int ORDERBITS = 5; int pows2[] = { 1,2,4,8,16,32,64,128 }; void send(int a); void output(int b); inline int readid(int num) { for (int i = SIZE - 1; i >= ORDERBITS; i--) { if (num - pows2[i] >= 0) { num -= pows2[i]; } } return num; } inline int readBit(int num) { int ans = 0; for (int i = SIZE - 1; i >= ORDERBITS; i--) { if (num - pows2[i] >= 0) { num -= pows2[i]; ans += pows2[i - ORDERBITS]; } } return ans; } inline int getShift(int num) { int ans = 0; for (int i = SIZE - ORDERBITS - 1;i >= 0;i--) { if (num - pows2[i] >= 0) { ans += pows2[i + ORDERBITS]; num -= pows2[i]; } } return ans; } inline void sendForNum(int num, int index) { for (int i = SIZE - 1;i >= 0;i--) { if (num - pows2[i] >= 0) { num -= pows2[i]; int curr = index + getShift(i); send(curr); } } } void decode(int N, int L, int X[]) { vi arr(N); for (int i = 0;i < L;i++) { int index = readid(X[i]); arr[index] += pows2[readBit(X[i])]; } for (int i = 0;i < arr.size();i++) { output(arr[i]); } }

Compilation message (stderr)

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