제출 #1310830

#제출 시각아이디문제언어결과실행 시간메모리
1310830nikoloz-chData Transfer (IOI19_transfer)C++20
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> #include "transfer.h" using namespace std; vector<int> get_attachment(vector<int> source){ int p = 0, n = source.size(), k = 0; for(int i = 0; i < n; i++) if(source[i]) p ^= source[i]; auto t = bitset<(n == 63 ? 6 : 8)>(p); for(int i = 0; i < t.size(); i++) source.push_back(t[i]), k += (t[i] ? 1 : 0); source.push_back(k % 2); } vector<int> retrieve(vector<int> data){ int p = 0, n = data.size(), k = 0, kp = 0; for(int i = 0; i < n-(n >= 255 ? 9 : 7); i++) if(data[i]) p ^= data[i]; for(int i = n; i < n+(n >= 255 ? 8 : 6); i++){ if(data[i]) k += (1<<(i-n)); kp += (data[i] ? 1 : 0) } vector<int> ans; if(data.back() != kp % 2){ for(int i = 0; i < n-(n >= 255 ? 9 : 7); i++) ans.push_back(data[i]); return ans; } for(int i = 0; i < n-(n >= 255 ? 9 : 7); i++){ if(i == (p^k)) ans.push_back((data[i] ? 0 : 1)); else ans.push_back(data[i]); } return ans; }

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

transfer.cpp: In function 'std::vector<int> get_attachment(std::vector<int>)':
transfer.cpp:8:37: error: the value of 'n' is not usable in a constant expression
    8 |     auto t = bitset<(n == 63 ? 6 : 8)>(p);
      |                                     ^
transfer.cpp:6:16: note: 'int n' is not const
    6 |     int p = 0, n = source.size(), k = 0;
      |                ^
transfer.cpp:8:38: error: the value of 'n' is not usable in a constant expression
    8 |     auto t = bitset<(n == 63 ? 6 : 8)>(p);
      |                                      ^
transfer.cpp:6:16: note: 'int n' is not const
    6 |     int p = 0, n = source.size(), k = 0;
      |                ^
transfer.cpp:8:30: note: in template argument for type 'long unsigned int'
    8 |     auto t = bitset<(n == 63 ? 6 : 8)>(p);
      |                     ~~~~~~~~~^~~~~~~~
transfer.cpp:11:1: warning: no return statement in function returning non-void [-Wreturn-type]
   11 | }
      | ^
transfer.cpp: In function 'std::vector<int> retrieve(std::vector<int>)':
transfer.cpp:18:32: error: expected ';' before '}' token
   18 |         kp += (data[i] ? 1 : 0)
      |                                ^
      |                                ;
   19 |     }
      |     ~                           
grader.cpp: In instantiation of 'void shuffle(std::vector<T>&) [with T = Scenario]':
grader.cpp:200:10:   required from here
grader.cpp:28:23: warning: 'void std::random_shuffle(_RAIter, _RAIter) [with _RAIter = __gnu_cxx::__normal_iterator<Scenario*, vector<Scenario> >]' is deprecated: use 'std::shuffle' instead [-Wdeprecated-declarations]
   28 |         random_shuffle(v.begin(), v.end());
      |         ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/13/algorithm:61,
                 from grader.cpp:8:
/usr/include/c++/13/bits/stl_algo.h:4581:5: note: declared here
 4581 |     random_shuffle(_RandomAccessIterator __first, _RandomAccessIterator __last)
      |     ^~~~~~~~~~~~~~