Submission #866955

#TimeUsernameProblemLanguageResultExecution timeMemory
866955tothanhdat1421Bali Sculptures (APIO15_sculpture)C++14
50 / 100
93 ms600 KiB
/* ======================== INCL ======================== */ #include <iostream> #include <fstream> #include <math.h> #include <algorithm> #include <vector> #include <stack> #include <queue> #include <map> #include <bitset> using namespace std; /* Code by { To Thanh Dat } 12TT THPT Chuyen Ben Tre */ /* ========================TEMPLATE======================== */ #define ll long long #define ull unsigned long long #define pii pair<int, int> #define vi vector<int> #define vii vector<pair<int, int>> #define mii map<int, int> #define pb push_back #define eb emplace_back #define mp make_pair #define fi first #define se second #define For(i, a, b) for(int i=a; i<=b; ++i) #define rFor(i, a, b) for(int i=a; i>=b; --i) #define Rep(i, n) for(int i = 0; i < (int)n; ++i) #define rRep(i, n) for(int i = (int)n - 1; i >= 0; --i) /* ========================CONSTANT======================== */ const int intINF = -1 ^ (1<<31); const ll llINF = -1LL ^ (1LL << 63); const int mod = 1e9+7; const int N = 2000+5; /* ========================VARIABLE======================== */ int n, A, B; ll a[N]; int F[N]; /* ======================== MAIN ======================== */ bool can(ll mask) { For(i, 1, n+1) F[i] = 1e5; F[1] = 0; For(i, 1, n) { if(F[i] >= 1e5) continue; ll cursum = 0; For(j, i, n) { cursum += a[j]; if((cursum & mask) == 0) { F[j+1] = min(F[j+1], 1 + F[i]); } } } // cout << "mask = " << mask << endl; // For(i, 0, n) cout << F[i] << ' '; // cout << endl; return (A <= F[n+1] && F[n+1] <= B); } int main() { if(fopen("APIO15_sculpture.inp", "r")) { freopen("APIO15_sculpture.inp", "r", stdin); freopen("APIO15_sculpture.out", "w", stdout); } ios_base::sync_with_stdio(0); cin.tie(NULL); cin >> n >> A >> B; For(i, 1, n) cin >> a[i]; // pref[0] = 0; // For(i, 1, n) pref[i] = pref[i-1] + a[i]; ll cur_mask = 0; rFor(i, 60, 0) { if(can(cur_mask | (1ll << i))) { cur_mask = cur_mask | (1ll << i); // cout << " => cur mask = " << cur_mask << endl; } } cout << ((1ll << 61)-1 - cur_mask); return 0; }

Compilation message (stderr)

sculpture.cpp: In function 'int main()':
sculpture.cpp:75:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   75 |         freopen("APIO15_sculpture.inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
sculpture.cpp:76:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   76 |         freopen("APIO15_sculpture.out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#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...