結果
問題 | No.5002 stick xor |
ユーザー | kimiyuki |
提出日時 | 2018-05-26 00:06:01 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 36 ms / 1,000 ms |
コード長 | 2,774 bytes |
コンパイル時間 | 5,045 ms |
実行使用メモリ | 1,536 KB |
スコア | 33,167 |
最終ジャッジ日時 | 2018-05-26 00:06:08 |
ジャッジサーバーID (参考情報) |
judge9 / |
純コード判定しない問題か言語 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 21 ms
1,532 KB |
testcase_01 | AC | 21 ms
1,536 KB |
testcase_02 | AC | 21 ms
1,532 KB |
testcase_03 | AC | 21 ms
1,528 KB |
testcase_04 | AC | 21 ms
1,524 KB |
testcase_05 | AC | 20 ms
1,528 KB |
testcase_06 | AC | 20 ms
1,532 KB |
testcase_07 | AC | 21 ms
1,532 KB |
testcase_08 | AC | 22 ms
1,536 KB |
testcase_09 | AC | 21 ms
1,528 KB |
testcase_10 | AC | 21 ms
1,528 KB |
testcase_11 | AC | 21 ms
1,532 KB |
testcase_12 | AC | 21 ms
1,532 KB |
testcase_13 | AC | 21 ms
1,532 KB |
testcase_14 | AC | 21 ms
1,532 KB |
testcase_15 | AC | 21 ms
1,536 KB |
testcase_16 | AC | 26 ms
1,528 KB |
testcase_17 | AC | 21 ms
1,536 KB |
testcase_18 | AC | 26 ms
1,532 KB |
testcase_19 | AC | 29 ms
1,536 KB |
testcase_20 | AC | 20 ms
1,528 KB |
testcase_21 | AC | 32 ms
1,532 KB |
testcase_22 | AC | 33 ms
1,528 KB |
testcase_23 | AC | 36 ms
1,536 KB |
testcase_24 | AC | 32 ms
1,532 KB |
testcase_25 | AC | 21 ms
1,528 KB |
testcase_26 | AC | 21 ms
1,532 KB |
testcase_27 | AC | 20 ms
1,528 KB |
testcase_28 | AC | 21 ms
1,532 KB |
testcase_29 | AC | 21 ms
1,532 KB |
testcase_30 | AC | 21 ms
1,528 KB |
testcase_31 | AC | 20 ms
1,532 KB |
ソースコード
#include <bits/stdc++.h> #define REP(i, n) for (int i = 0; (i) < int(n); ++ (i)) #define REP3(i, m, n) for (int i = (m); (i) < int(n); ++ (i)) #define REP_R(i, n) for (int i = int(n) - 1; (i) >= 0; -- (i)) #define REP3R(i, m, n) for (int i = int(n) - 1; (i) >= int(m); -- (i)) #define ALL(x) begin(x), end(x) #define dump(x) cerr << #x " = " << x << endl #define unittest_name_helper(counter) unittest_ ## counter #define unittest_name(counter) unittest_name_helper(counter) #define unittest __attribute__((constructor)) void unittest_name(__COUNTER__) () using ll = long long; using namespace std; template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >; template <class T> inline void chmax(T & a, T const & b) { a = max(a, b); } template <class T> inline void chmin(T & a, T const & b) { a = min(a, b); } template <typename X, typename T> auto vectors(X x, T a) { return vector<T>(x, a); } template <typename X, typename Y, typename Z, typename... Zs> auto vectors(X x, Y y, Z z, Zs... zs) { auto cont = vectors(y, z, zs...); return vector<decltype(cont)>(x, cont); } template <typename T> ostream & operator << (ostream & out, vector<T> const & xs) { REP (i, int(xs.size()) - 1) out << xs[i] << ' '; if (not xs.empty()) out << xs.back(); return out; } vector<tuple<int, int, bool> > solve(int n, int k, vector<int> const & l, vector<vector<bool> > a) { vector<vector<int> > lookup(n + 1); REP (i, k) lookup[l[i]].push_back(i); vector<tuple<int, int, bool> > result(k); REP_R (len, n + 1) { reverse(ALL(lookup[len])); // for better visualization for (int i : lookup[len]) { int highscore = -1; REP (y, n - len) REP (x, n) { int score = 0; REP (dy, len) score += a[y + dy][x]; if (highscore < score) { highscore = score; result[i] = make_tuple(y, x, false); } } int y, x; tie(y, x, ignore) = result[i]; REP (dy, len) { auto && p = a[y + dy][x]; p = not p; } } } return result; } int main() { // input int n, k; cin >> n >> k; vector<int> l(k); REP (i, k) cin >> l[i]; auto a = vectors(n, n, bool()); REP (y, n) REP (x, n) { char c; cin >> c; a[y][x] = c - '0'; } // solve vector<tuple<int, int, bool> > result = solve(n, k, l, a); // output REP (i, k) { int y, x; bool is_vertical; tie(y, x, is_vertical) = result[i]; int ny = y; int nx = x; (is_vertical ? nx : ny) += l[i] - 1; cout << y + 1 << ' ' << x + 1 << ' ' << ny + 1 << ' ' << nx + 1 << endl; } return 0; }