結果
問題 | No.5013 セクスタプル (open) |
ユーザー | ks2m |
提出日時 | 2022-12-29 17:33:47 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 1,906 ms / 2,000 ms |
コード長 | 3,334 bytes |
コンパイル時間 | 3,169 ms |
実行使用メモリ | 68,580 KB |
スコア | 17,588 |
最終ジャッジ日時 | 2022-12-29 17:38:37 |
合計ジャッジ時間 | 200,224 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge11 |
純コード判定しない問題か言語 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1,895 ms
59,552 KB |
testcase_01 | AC | 1,893 ms
58,860 KB |
testcase_02 | AC | 1,896 ms
59,480 KB |
testcase_03 | AC | 1,894 ms
59,052 KB |
testcase_04 | AC | 1,896 ms
58,992 KB |
testcase_05 | AC | 1,902 ms
68,580 KB |
testcase_06 | AC | 1,906 ms
58,900 KB |
testcase_07 | AC | 1,897 ms
58,844 KB |
testcase_08 | AC | 1,898 ms
59,028 KB |
testcase_09 | AC | 1,895 ms
59,396 KB |
testcase_10 | AC | 1,893 ms
59,440 KB |
testcase_11 | AC | 1,894 ms
58,932 KB |
testcase_12 | AC | 1,894 ms
59,048 KB |
testcase_13 | AC | 1,893 ms
60,148 KB |
testcase_14 | AC | 1,893 ms
59,332 KB |
testcase_15 | AC | 1,901 ms
59,484 KB |
testcase_16 | AC | 1,894 ms
59,392 KB |
testcase_17 | AC | 1,893 ms
59,008 KB |
testcase_18 | AC | 1,895 ms
59,456 KB |
testcase_19 | AC | 1,894 ms
59,132 KB |
testcase_20 | AC | 1,895 ms
59,120 KB |
testcase_21 | AC | 1,901 ms
58,604 KB |
testcase_22 | AC | 1,894 ms
59,800 KB |
testcase_23 | AC | 1,894 ms
59,564 KB |
testcase_24 | AC | 1,893 ms
59,116 KB |
testcase_25 | AC | 1,894 ms
58,876 KB |
testcase_26 | AC | 1,893 ms
59,152 KB |
testcase_27 | AC | 1,893 ms
58,928 KB |
testcase_28 | AC | 1,894 ms
59,036 KB |
testcase_29 | AC | 1,894 ms
59,584 KB |
testcase_30 | AC | 1,894 ms
58,956 KB |
testcase_31 | AC | 1,893 ms
59,144 KB |
testcase_32 | AC | 1,896 ms
59,544 KB |
testcase_33 | AC | 1,894 ms
58,952 KB |
testcase_34 | AC | 1,895 ms
58,980 KB |
testcase_35 | AC | 1,891 ms
58,968 KB |
testcase_36 | AC | 1,891 ms
59,140 KB |
testcase_37 | AC | 1,894 ms
59,364 KB |
testcase_38 | AC | 1,894 ms
58,972 KB |
testcase_39 | AC | 1,891 ms
59,352 KB |
testcase_40 | AC | 1,895 ms
59,520 KB |
testcase_41 | AC | 1,892 ms
58,924 KB |
testcase_42 | AC | 1,892 ms
59,180 KB |
testcase_43 | AC | 1,894 ms
59,140 KB |
testcase_44 | AC | 1,893 ms
58,832 KB |
testcase_45 | AC | 1,893 ms
59,136 KB |
testcase_46 | AC | 1,892 ms
58,772 KB |
testcase_47 | AC | 1,893 ms
59,044 KB |
testcase_48 | AC | 1,892 ms
59,564 KB |
testcase_49 | AC | 1,895 ms
59,492 KB |
testcase_50 | AC | 1,894 ms
59,200 KB |
testcase_51 | AC | 1,894 ms
59,320 KB |
testcase_52 | AC | 1,894 ms
59,124 KB |
testcase_53 | AC | 1,895 ms
60,832 KB |
testcase_54 | AC | 1,892 ms
58,816 KB |
testcase_55 | AC | 1,893 ms
59,328 KB |
testcase_56 | AC | 1,893 ms
59,288 KB |
testcase_57 | AC | 1,896 ms
59,224 KB |
testcase_58 | AC | 1,896 ms
58,936 KB |
testcase_59 | AC | 1,896 ms
58,948 KB |
testcase_60 | AC | 1,897 ms
58,920 KB |
testcase_61 | AC | 1,896 ms
59,156 KB |
testcase_62 | AC | 1,897 ms
58,956 KB |
testcase_63 | AC | 1,894 ms
58,812 KB |
testcase_64 | AC | 1,896 ms
59,044 KB |
testcase_65 | AC | 1,894 ms
59,164 KB |
testcase_66 | AC | 1,893 ms
58,904 KB |
testcase_67 | AC | 1,892 ms
59,228 KB |
testcase_68 | AC | 1,896 ms
59,132 KB |
testcase_69 | AC | 1,894 ms
59,156 KB |
testcase_70 | AC | 1,892 ms
59,068 KB |
testcase_71 | AC | 1,894 ms
59,080 KB |
testcase_72 | AC | 1,894 ms
58,896 KB |
testcase_73 | AC | 1,893 ms
58,952 KB |
testcase_74 | AC | 1,893 ms
59,444 KB |
testcase_75 | AC | 1,896 ms
59,244 KB |
testcase_76 | AC | 1,894 ms
59,724 KB |
testcase_77 | AC | 1,895 ms
58,960 KB |
testcase_78 | AC | 1,897 ms
59,260 KB |
testcase_79 | AC | 1,893 ms
58,920 KB |
testcase_80 | AC | 1,893 ms
59,372 KB |
testcase_81 | AC | 1,898 ms
59,532 KB |
testcase_82 | AC | 1,895 ms
58,992 KB |
testcase_83 | AC | 1,891 ms
58,932 KB |
testcase_84 | AC | 1,893 ms
58,916 KB |
testcase_85 | AC | 1,893 ms
59,464 KB |
testcase_86 | AC | 1,894 ms
61,108 KB |
testcase_87 | AC | 1,894 ms
58,988 KB |
testcase_88 | AC | 1,892 ms
59,136 KB |
testcase_89 | AC | 1,893 ms
61,056 KB |
testcase_90 | AC | 1,892 ms
59,460 KB |
testcase_91 | AC | 1,893 ms
59,060 KB |
testcase_92 | AC | 1,894 ms
58,944 KB |
testcase_93 | AC | 1,893 ms
59,160 KB |
testcase_94 | AC | 1,894 ms
58,808 KB |
testcase_95 | AC | 1,893 ms
61,328 KB |
testcase_96 | AC | 1,895 ms
62,916 KB |
testcase_97 | AC | 1,894 ms
63,276 KB |
testcase_98 | AC | 1,890 ms
62,876 KB |
testcase_99 | AC | 1,890 ms
63,348 KB |
ソースコード
import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.Arrays; import java.util.List; public class Main { static int n = 6; static int nn = 36; public static void main(String[] args) throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); solve1(br); br.close(); } static void solve1(BufferedReader br) throws Exception { List<Obj> list = new ArrayList<>(nn); for (int i = 0; i < nn; i++) { String[] sa = br.readLine().split(" "); Obj o = new Obj(); for (int j = 0; j < n; j++) { o.d[j] = Integer.parseInt(sa[j]) - 1; o.cnt[o.d[j]]++; o.ex[o.d[j]] = true; } list.add(o); } f = new Obj[n][n]; for (int i = 0; i < nn; i++) { int x = i / n; int y = i % n; f[x][y] = list.get(i); } int chgNum = 3; List<Integer> chgPos = new ArrayList<>(chgNum); bestWk = new int[chgNum]; chgObj = new ArrayList<>(chgNum); long limitTime = 1800; long startTime = System.currentTimeMillis(); while (true) { long time = System.currentTimeMillis() - startTime; if (time > limitTime) { break; } chgPos.clear(); chgObj.clear(); for (int i = 0; i < chgNum; i++) { int p = rand36(); while (chgPos.contains(p)) { p = rand36(); } chgPos.add(p); chgObj.add(f[p / n][p % n]); } newScore = 0; permutation(chgPos, 0, 0, new int[chgNum]); for (int i = 0; i < chgNum; i++) { int x = bestWk[i] / n; int y = bestWk[i] % n; f[x][y] = chgObj.get(i); } } for (int x = 0; x < n; x++) { for (int y = 0; y < n; y++) { f[x][y].x = x + 1; f[x][y].y = y + 1; } } for (Obj o : list) { System.out.println(o.x + " " + o.y); } System.out.println(newScore); } static int newScore; static int[] bestWk; static Obj[][] f; static List<Obj> chgObj; static void permutation(List<Integer> org, int used, int idx, int[] wk) { if (idx == org.size()) { for (int i = 0; i < idx; i++) { int x = wk[i] / n; int y = wk[i] % n; f[x][y] = chgObj.get(i); } int res = score(f); if (res >= newScore) { newScore = res; for (int i = 0; i < idx; i++) { bestWk[i] = wk[i]; } } return; } for (int i = 0; i < org.size(); i++) { if ((used >> i & 1) == 0) { wk[idx] = org.get(i); permutation(org, used | 1 << i, idx + 1, wk); } } } static int rand36() { return (int) (Math.random() * 36); } static int score(Obj[][] f) { int ret = 0; List<Obj> list = new ArrayList<>(n); for (int x = 0; x < n; x++) { for (int y = 0; y < n; y++) { list.add(f[x][y]); } ret += lineScore(list); list.clear(); } for (int y = 0; y < n; y++) { for (int x = 0; x < n; x++) { list.add(f[x][y]); } ret += lineScore(list); list.clear(); } return ret; } static int lineScore(List<Obj> list) { boolean[] ex = new boolean[n]; Arrays.fill(ex, true); int[] cnt = new int[n]; for (Obj o : list) { for (int i = 0; i < n; i++) { ex[i] = ex[i] && o.ex[i]; cnt[i] += o.cnt[i]; } } int ret = 0; for (int i = 0; i < n; i++) { if (ex[i]) { ret += cnt[i] - 3; } } return ret; } static class Obj { int x, y; int[] d = new int[n]; int[] cnt = new int[n]; boolean[] ex = new boolean[n]; } }