Submission #314871

#TimeUsernameProblemLanguageResultExecution timeMemory
314871kostia244Packing Biscuits (IOI20_biscuits)C++17
Compilation error
0 ms0 KiB
#include "biscuits.h" #include<bits/stdc++.h> #define all(x) begin(x), end(x) using namespace std; using ll = long long; const int B = 126; vector<ll> convert(__int128 x) { vector<ll> a(B); for(int i = 0; i < B; i++) a[i] += x&1, x/=2; return a; } ll count_tastiness(ll x, vector<ll> a) { __int128 k = 0; a.resize(B); vector<vector<ll>> con; for(int i = 0; i < B; i++) { k += __int128(a[i])<<i; if((k/x) < (__int128(2)<<i)) con.push_back(convert(k/x)); } for(auto &i : con) reverse(all(i)); ll dp[128][128]; memset(dp, 0, sizeof dp); dp[0][con.size()] = 1; for(int i = 0; i < B; i++) { for(int j = 0; j <= con.size(); j++) { //if(dp[i][j]) cout << i << " " << j << " " << dp[i][j] << endl; int tj = j; while(tj && con[tj-1][i] == 1) tj--; dp[i+1][tj] += dp[i][j];//place 0 int can1 = 1; for(int k = B-i-1; k < j; k++) can1 &= con[k][i] == 1; if(can1) dp[i+1][j] += dp[i][j]; } } ll ans = 0; for(int i = 0; i <= con.size(); i++) ans += dp[B][i]; return ans; } #include "biscuits.h" #include<bits/stdc++.h> #define all(x) begin(x), end(x) using namespace std; using ll = long long; const int B = 126; vector<ll> convert(__int128 x) { vector<ll> a(B); for(int i = 0; i < B; i++) a[i] += x&1, x/=2; return a; } ll count_tastiness(ll x, vector<ll> a) { __int128 k = 0; a.resize(B); vector<vector<ll>> con; for(int i = 0; i < B; i++) { k += __int128(a[i])<<i; if((k/x) < (__int128(2)<<i)) con.push_back(convert(k/x)); } for(auto &i : con) reverse(all(i)); ll dp[128][128]; memset(dp, 0, sizeof dp); dp[0][con.size()] = 1; for(int i = 0; i < B; i++) { for(int j = 0; j <= con.size(); j++) { //if(dp[i][j]) cout << i << " " << j << " " << dp[i][j] << endl; int tj = j; while(tj && con[tj-1][i] == 1) tj--; dp[i+1][tj] += dp[i][j];//place 0 int can1 = 1; for(int k = B-i-1; k < j; k++) can1 &= con[k][i] == 1; if(can1) dp[i+1][j] += dp[i][j]; } } ll ans = 0; for(int i = 0; i <= con.size(); i++) ans += dp[B][i]; return ans; }

Compilation message (stderr)

biscuits.cpp: In function 'll count_tastiness(ll, std::vector<long long int>)':
biscuits.cpp:26:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |   for(int j = 0; j <= con.size(); j++) {
      |                  ~~^~~~~~~~~~~~~
biscuits.cpp:37:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 |  for(int i = 0; i <= con.size(); i++) ans += dp[B][i];
      |                 ~~^~~~~~~~~~~~~
biscuits.cpp: At global scope:
biscuits.cpp:46:11: error: redefinition of 'const int B'
   46 | const int B = 126;
      |           ^
biscuits.cpp:6:11: note: 'const int B' previously defined here
    6 | const int B = 126;
      |           ^
biscuits.cpp:47:12: error: redefinition of 'std::vector<long long int> convert(__int128)'
   47 | vector<ll> convert(__int128 x) {
      |            ^~~~~~~
biscuits.cpp:7:12: note: 'std::vector<long long int> convert(__int128)' previously defined here
    7 | vector<ll> convert(__int128 x) {
      |            ^~~~~~~
biscuits.cpp:52:4: error: redefinition of 'll count_tastiness(ll, std::vector<long long int>)'
   52 | ll count_tastiness(ll x, vector<ll> a) {
      |    ^~~~~~~~~~~~~~~
biscuits.cpp:12:4: note: 'long long int count_tastiness(long long int, std::vector<long long int>)' previously defined here
   12 | ll count_tastiness(ll x, vector<ll> a) {
      |    ^~~~~~~~~~~~~~~
biscuits.cpp: In function 'll count_tastiness(ll, std::vector<long long int>)':
biscuits.cpp:66:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   66 |   for(int j = 0; j <= con.size(); j++) {
      |                  ~~^~~~~~~~~~~~~
biscuits.cpp:77:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   77 |  for(int i = 0; i <= con.size(); i++) ans += dp[B][i];
      |                 ~~^~~~~~~~~~~~~