제출 #703946

#제출 시각아이디문제언어결과실행 시간메모리
703946boyliguanhanData Transfer (IOI19_transfer)C++17
100 / 100
128 ms2500 KiB
#include "transfer.h" #include <bits/stdc++.h> #define bit(v) ( v.size() < 99 ? 6 : 8) using namespace std; vector<int> convert(int org, int bits) { vector<int> res(bits); for (int i = 0; i < bits; i++) res[i] = (bool)(org & 1 << i); return res; } int change(vector<int> v) { int xored = 0; for (int i = 0; i < v.size(); i++) if (v[i]) xored ^= i + 1; return xored; } int rev(vector<int> v) { int n = 0; for (int i = 0; i < v.size(); i++) n += v[i] << i; return n; } std::vector<int> get_attachment(std::vector<int> source) { vector<int> res = convert(change(source), bit(source)); res.push_back(count(source.begin(), source.end(), 1) % 2); return res; } bool corrupt(vector<int> v) { return vector<int>(v.end() - bit(v), v.end()) != convert(change(vector<int>(v.begin(), v.end() - bit(v))), bit(v)); } std::vector<int> retrieve(std::vector<int> data) { vector<int> res = std::vector<int>(data.begin(), data.end() - bit(data) - 1); int x = count(res.begin(), res.end(), 1); if (corrupt(std::vector<int>(data.begin(), data.end() - 1))) { if (x % 2 != data[data.size() - 1]) { int cb = rev(vector<int>(data.end() - bit(data) - 1, data.end() - 1)) ^ change(vector<int>(data.begin(), data.end() - bit(data) - 1)); res[cb - 1] = !res[cb - 1]; } } return res; }

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

transfer.cpp: In function 'int change(std::vector<int>)':
transfer.cpp:13:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   13 |  for (int i = 0; i < v.size(); i++)
      |                  ~~^~~~~~~~~~
transfer.cpp: In function 'int rev(std::vector<int>)':
transfer.cpp:20:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   20 |  for (int i = 0; i < v.size(); i++)
      |                  ~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...