結果

問題 No.5002 stick xor
ユーザー ei1333333ei1333333
提出日時 2018-05-26 02:13:02
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 48 ms / 1,000 ms
コード長 1,615 bytes
コンパイル時間 4,959 ms
実行使用メモリ 1,552 KB
スコア 39,737
最終ジャッジ日時 2018-05-26 02:13:10
ジャッジサーバーID
(参考情報)
judge8 /
純コード判定しない問題か言語
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 45 ms
1,552 KB
testcase_01 AC 42 ms
1,552 KB
testcase_02 AC 45 ms
1,548 KB
testcase_03 AC 43 ms
1,548 KB
testcase_04 AC 43 ms
1,552 KB
testcase_05 AC 43 ms
1,552 KB
testcase_06 AC 42 ms
1,552 KB
testcase_07 AC 46 ms
1,548 KB
testcase_08 AC 44 ms
1,544 KB
testcase_09 AC 45 ms
1,548 KB
testcase_10 AC 44 ms
1,544 KB
testcase_11 AC 48 ms
1,548 KB
testcase_12 AC 47 ms
1,552 KB
testcase_13 AC 44 ms
1,548 KB
testcase_14 AC 46 ms
1,548 KB
testcase_15 AC 42 ms
1,548 KB
testcase_16 AC 46 ms
1,548 KB
testcase_17 AC 45 ms
1,548 KB
testcase_18 AC 44 ms
1,548 KB
testcase_19 AC 44 ms
1,552 KB
testcase_20 AC 44 ms
1,552 KB
testcase_21 AC 44 ms
1,548 KB
testcase_22 AC 44 ms
1,552 KB
testcase_23 AC 47 ms
1,548 KB
testcase_24 AC 44 ms
1,552 KB
testcase_25 AC 43 ms
1,552 KB
testcase_26 AC 44 ms
1,544 KB
testcase_27 AC 44 ms
1,544 KB
testcase_28 AC 46 ms
1,548 KB
testcase_29 AC 47 ms
1,548 KB
testcase_30 AC 44 ms
1,548 KB
testcase_31 AC 44 ms
1,552 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

int main() {
  int N, K, L[500];
  bool t[60][60];

  cin >> N >> K;
  for(int i = 0; i < K; i++) {
    cin >> L[i];
  }
  int pv = 0;
  for(int i = 0; i < N; i++) {
    string s;
    cin >> s;
    for(int j = 0; j < N; j++) {
      t[i][j] = s[j] == '0';
      pv += t[i][j];
    }
  }

  vector< int > length[26];
  for(int i = 0; i < K; i++) {
    length[L[i]].push_back(i);
  }
  int A[500], B[500], C[500], D[500];

  int ret = 0;

  for(int i = 25; i >= 0; i--) {
    for(int j : length[i]) {
      int best = -55;
      int a, b, c;
      for(int x = 0; x < N; x++) {
        for(int y = 0; y <= N - i; y++) {
          int add = 0;
          for(int k = 0; k < i; k++) {
            add += t[y + k][x] ? -1 : 1;
          }
          if(best < add) {
            best = add;
            a = y, b = x, c = 0;
          }
        }
      }
      for(int y = 0; y < N; y++) {
        for(int x = 0; x <= N - i; x++) {
          int add = 0;
          for(int k = 0; k < i; k++) {
            add += t[y][x + k] ? -1 : 1;
          }
          if(best < add) {
            best = add;
            a = y, b = x, c = 1;
          }
        }
      }
      ret += best;

      if(c == 0) {
        for(int k = 0; k < i; k++) t[a + k][b] ^= 1;
        A[j] = a, B[j] = b, C[j] = a + i - 1, D[j] = b;
      } else {
        for(int k = 0; k < i; k++) t[a][b + k] ^= 1;
        A[j] = a, B[j] = b, C[j] = a, D[j] = b + i - 1;
      }
    }
  }


  for(int i = 0; i < K; i++) {
    cout << A[i] + 1 << " " << B[i] + 1 << " " << C[i] + 1 << " " << D[i] + 1 << endl;
  }
}
0