제출 #866957

#제출 시각아이디문제언어결과실행 시간메모리
866957tothanhdat1421Bali Sculptures (APIO15_sculpture)C++14
50 / 100
92 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]; bool F2[105][105]; /* ======================== 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); } bool can2(ll mask) { For(i, 1, n) For(j, 1, n) F2[i][j] = 0; For(j, 0, B) { For(i, 1, n) { if(F2[i][j]) { ll cur_sum = 0; For(k, i, n) { cur_sum += a[k]; if((cur_sum & mask) == 0) { F2[k+1][j+1] = 1; } } } } } For(i, A, B) { if(F2[n][i]) return 1; } return 0; } 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(A == 1) { if(can(cur_mask | (1ll << i))) { cur_mask = cur_mask | (1ll << i); // cout << " => cur mask = " << cur_mask << endl; } } else { if(can2(cur_mask | (1ll << i))) { cur_mask = cur_mask | (1ll << i); // cout << " => cur mask = " << cur_mask << endl; } } } cout << ((1ll << 61)-1 - cur_mask); return 0; }

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

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