Submission #396479

#TimeUsernameProblemLanguageResultExecution timeMemory
396479Kevin_Zhang_TW벽 칠하기 (APIO20_paint)C++17
0 / 100
1 ms204 KiB
#include <bits/stdc++.h> #include "paint.h" using namespace std; using ll = long long; #define pb emplace_back #define AI(i) begin(i), end(i) template<class T> bool chmin(T &a, T b) { return b < a && (a = b, true); } template<class T> bool chmax(T &a, T b) { return a < b && (a = b, true); } #ifdef KEV #define DE(args...) kout("[ " + string(#args) + " ] = ", args) void kout() { cerr << endl; } template<class T, class ...U> void kout(T a, U ...b) { cerr << a << ' ', kout(b...); } template<class T> void debug(T l, T r) { while (l != r) cerr << *l << " \n"[next(l)==r], ++l; } #else #define DE(...) 0 #define debug(...) 0 #endif const int inf = 1e9 + 7; int minimumInstructions( int N, int M, int K, std::vector<int> C, std::vector<int> A, std::vector<std::vector<int>> B) { for (int i = 0;i < M;++i) sort(AI(B[i])); vector<int> ok; for (int i = 0;i <= N-M;++i) { auto valid = [&](int i, int j) { for (int k = 0;k < M;++k) { if (!binary_search(AI(B[(j+k)%M]), C[i+k])) return false; } return true; }; for (int j = 0;j < M;++j) if (valid(i, j)) { ok.pb(i); break; } } // good is the max index I can take int res = 0, good = 0, bst = -1; ok.pb(N); for (int id : ok) { DE(res, good, bst, id); if (id > good) { if (bst == -1) return -1; ++res; good = bst + M; bst = -1; } if (id <= good) chmax(bst, id); } return res; }

Compilation message (stderr)

paint.cpp: In function 'int minimumInstructions(int, int, int, std::vector<int>, std::vector<int>, std::vector<std::vector<int> >)':
paint.cpp:15:17: warning: statement has no effect [-Wunused-value]
   15 | #define DE(...) 0
      |                 ^
paint.cpp:52:3: note: in expansion of macro 'DE'
   52 |   DE(res, good, bst, id);
      |   ^~
#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...