結果
問題 | No.1136 Four Points Tour |
ユーザー | RISE70226821 |
提出日時 | 2020-09-29 16:32:23 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 107 ms / 2,000 ms |
コード長 | 2,695 bytes |
コンパイル時間 | 1,987 ms |
コンパイル使用メモリ | 77,104 KB |
実行使用メモリ | 55,228 KB |
最終ジャッジ日時 | 2024-07-04 00:31:28 |
合計ジャッジ時間 | 5,511 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 45 ms
36,976 KB |
testcase_01 | AC | 46 ms
37,352 KB |
testcase_02 | AC | 46 ms
37,172 KB |
testcase_03 | AC | 46 ms
36,936 KB |
testcase_04 | AC | 45 ms
37,408 KB |
testcase_05 | AC | 47 ms
37,300 KB |
testcase_06 | AC | 44 ms
36,880 KB |
testcase_07 | AC | 88 ms
46,244 KB |
testcase_08 | AC | 45 ms
37,248 KB |
testcase_09 | AC | 46 ms
36,796 KB |
testcase_10 | AC | 96 ms
49,896 KB |
testcase_11 | AC | 48 ms
37,420 KB |
testcase_12 | AC | 64 ms
38,836 KB |
testcase_13 | AC | 46 ms
36,888 KB |
testcase_14 | AC | 65 ms
38,600 KB |
testcase_15 | AC | 47 ms
36,820 KB |
testcase_16 | AC | 62 ms
39,120 KB |
testcase_17 | AC | 65 ms
39,068 KB |
testcase_18 | AC | 90 ms
47,672 KB |
testcase_19 | AC | 107 ms
55,228 KB |
testcase_20 | AC | 56 ms
37,292 KB |
testcase_21 | AC | 90 ms
47,612 KB |
01_Sample03_evil.txt | RE | - |
04_Rnd_large_evil1.txt | RE | - |
04_Rnd_large_evil2.txt | RE | - |
04_Rnd_large_evil3.txt | RE | - |
04_Rnd_large_evil4.txt | RE | - |
04_Rnd_large_evil5.txt | RE | - |
04_Rnd_large_evil6.txt | RE | - |
04_Rnd_large_evil7.txt | RE | - |
04_Rnd_large_evil8.txt | RE | - |
04_Rnd_large_evil9.txt | RE | - |
04_Rnd_large_evil10.txt | RE | - |
05_Rnd_huge_evil1.txt | RE | - |
05_Rnd_huge_evil2.txt | RE | - |
05_Rnd_huge_evil3.txt | RE | - |
05_Rnd_huge_evil4.txt | RE | - |
05_Rnd_huge_evil5.txt | RE | - |
05_Rnd_huge_evil6.txt | RE | - |
05_Rnd_huge_evil7.txt | RE | - |
99_evil_01.txt | RE | - |
ソースコード
import java.util.*; import java.lang.*; import java.io.*; public class Main { public static void main (String[] args) throws java.lang.Exception { // your code goes here // 入力 FastScanner sc = new FastScanner(System.in); int N = sc.nextInt(); int[][] dp = new int[4][N+10]; int DIV = 1000000007; // DP表の作成 dp[0][0] = 1; dp[1][0] = 0; dp[1][0] = 0; dp[1][0] = 0; for(int i = 0; i < N; i++){ dp[0][i+1] = mod(dp[1][i], dp[2][i], dp[3][i], DIV); dp[1][i+1] = mod(dp[0][i], dp[2][i], dp[3][i], DIV); dp[2][i+1] = mod(dp[0][i], dp[1][i], dp[3][i], DIV); dp[3][i+1] = mod(dp[0][i], dp[1][i], dp[2][i], DIV); } // 出力 System.out.println(dp[0][N]); } // 3数の和を指定数で割った余りを求める関数 public static int mod(int a, int b, int c, int DIV){ int result = (a + b) % DIV; result = (result + c) % DIV; return result; } // 高速スキャナー static class FastScanner { private BufferedReader reader = null; private StringTokenizer tokenizer = null; public FastScanner(InputStream in) { reader = new BufferedReader(new InputStreamReader(in)); tokenizer = null; } public String next() { if (tokenizer == null || !tokenizer.hasMoreTokens()) { try { tokenizer = new StringTokenizer(reader.readLine()); } catch (IOException e) { throw new RuntimeException(e); } } return tokenizer.nextToken(); } public String nextLine() { if (tokenizer == null || !tokenizer.hasMoreTokens()) { try { return reader.readLine(); } catch (IOException e) { throw new RuntimeException(e); } } return tokenizer.nextToken("\n"); } public long nextLong() { return Long.parseLong(next()); } public int nextInt() { return Integer.parseInt(next()); } public double nextDouble() { return Double.parseDouble(next()); } public int[] nextIntArray(int n) { int[] a = new int[n]; for (int i = 0; i < n; i++) a[i] = nextInt(); return a; } public long[] nextLongArray(int n) { long[] a = new long[n]; for (int i = 0; i < n; i++) a[i] = nextLong(); return a; } } }