Submission #125795

#TimeUsernameProblemLanguageResultExecution timeMemory
125795dragoonBali Sculptures (APIO15_sculpture)C++14
100 / 100
154 ms504 KiB
//#pragma GCC optimize("Ofast") //#pragma GCC optimize ("unroll-loops") //#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") #pragma warning(disable:4786) #pragma warning(disable:4996) #include <ctime> #include<list> #include <numeric> #include<bitset> #include<iostream> #include<cstdio> #include<algorithm> #include<vector> #include<set> #include<map> #include<functional> #include<string> #include<cstring> #include<cstdlib> #include<queue> #include<utility> #include<fstream> #include<sstream> #include<cmath> #include<stack> #include<assert.h> #include<unordered_map> #include<unordered_set> #include <array> using namespace std; #define sim template < class c #define ris return * this #define dor > debug & operator << #define eni(x) sim > typename \ enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) { sim > struct rge { c b, e; }; sim > rge<c> range(c i, c j) { return rge<c>{i, j}; } sim > auto dud(c* x) -> decltype(cerr << *x, 0); sim > char dud(...); struct debug { #ifdef LOCAL ~debug() { cerr << endl; } template<class c> typename enable_if<sizeof dud<c>(0) != 1, debug&>::type operator<<(c i) { cerr << boolalpha << i; return *this; } template<class c, int=0> typename enable_if<sizeof dud<c>(0) == 1, debug&>::type operator<<(c i) { return *this << range(begin(i), end(i)); } sim, class b dor(pair < b, c > d) { ris << "(" << d.first << ", " << d.second << ")"; } sim dor(rge<c> d) { *this << "["; for (auto it = d.b; it != d.e; ++it) *this << ", " + 2 * (it == d.b) << *it; ris << "]"; } #else sim dor(const c&) { ris; } #endif }; #define watch(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] " #define MEM(a, b) memset(a, (b), sizeof(a)) #define CLR(a) memset(a, 0, sizeof(a)) #define MAX(a, b) ((a) > (b) ? (a) : (b)) #define MIN(a, b) ((a) < (b) ? (a) : (b)) #define ABS(X) ( (X) > 0 ? (X) : ( -(X) ) ) #define S(X) ( (X) * (X) ) #define SZ(V) (int )V.size() #define FORN(i, n) for(int i = 0; i < n; i++) #define FORAB(i, a, b) for(int i = a; i <= b; i++) #define ALL(V) V.begin(), V.end() #define IN(A, B, C) ((B) <= (A) && (A) <= (C)) #define AIN(A, B, C) assert(IN(A, B, C)) //typedef int LL; typedef long long int LL; //typedef __int128 LLL; typedef long long LLL; typedef pair<int, int> PII; typedef pair<LL, LL> PLL; typedef pair<double, double> PDD; typedef vector<int> VI; typedef vector<LL> VL; typedef vector<PLL > VPL; typedef vector<PII > VP; typedef vector<double> VD; typedef long double ld; int n, a, b; LL y[2003], sy[2003]; int min_step[2003]; int Solve1(LL mask) { min_step[0] = 0; for (int i = 1; i <= n; i++) { min_step[i] = 1000000; for (int j = 1; j <= i; j++) { if (min_step[j - 1] == 1000000) continue; LL sum = sy[i] - sy[j - 1]; if ((sum & mask)) continue; min_step[i] = MIN(min_step[i], min_step[j - 1] + 1); } } return min_step[n] <= b; } int possible[102][102]; int SolveA(LL mask) { CLR(possible); possible[0][0] = 1; for (int i = 1; i <= n; i++) { for (int j = 0; j < i; j++) { for (int k = 0; k < n; k++) { if (!possible[j][k]) continue; LL sum = sy[i] - sy[j]; if ((sum & mask)) continue; possible[i][k + 1] = 1; } } } for (int i = a; i <= b; i++) if (possible[n][i]) return 1; return 0; } void solve(int ks) { scanf("%d %d %d", &n, &a, &b); for (int i = 1; i <= n; i++) scanf("%lld", &y[i]); FORAB(i, 1, n) sy[i] = y[i] + sy[i - 1]; LL ans = 0; for (int i = 49; i >= 0; i--) { ans |= (1LL << i); int is_possible = (a == 1 ? Solve1(ans) : SolveA(ans)); if (!is_possible) ans ^= (1LL << i); } ans ^= (1LL << 50) - 1; printf("%lld\n", ans); } int main() { #ifdef LOCAL double start_time = clock(); freopen("C:\\Home\\ContestCodes\\sample.in", "r", stdin); // freopen("out.out", "w", stdout); #endif if (0) { int T; scanf("%d", &T); //AIN(T, 1, 25); for (int ks = 1; ks <= T; ks++) solve(ks); } else { solve(0); } #ifdef LOCAL double end_time = clock(); fprintf(stderr, "Time = %lf\n", (end_time - start_time) / CLOCKS_PER_SEC); #endif return 0; }

Compilation message (stderr)

sculpture.cpp:5:0: warning: ignoring #pragma warning  [-Wunknown-pragmas]
 #pragma warning(disable:4786)
 
sculpture.cpp:6:0: warning: ignoring #pragma warning  [-Wunknown-pragmas]
 #pragma warning(disable:4996)
 
sculpture.cpp: In function 'void solve(int)':
sculpture.cpp:133:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d %d", &n, &a, &b);
  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
sculpture.cpp:134:36: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for (int i = 1; i <= n; i++) scanf("%lld", &y[i]);
                               ~~~~~^~~~~~~~~~~~~~~
sculpture.cpp: In function 'int main()':
sculpture.cpp:158:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &T);
   ~~~~~^~~~~~~~~~
#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...