結果
問題 | No.1373 Directed Operations |
ユーザー | FromBooska |
提出日時 | 2023-02-23 09:53:06 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 503 ms / 2,000 ms |
コード長 | 913 bytes |
コンパイル時間 | 301 ms |
コンパイル使用メモリ | 87,096 KB |
実行使用メモリ | 102,076 KB |
最終ジャッジ日時 | 2023-09-30 13:19:51 |
合計ジャッジ時間 | 7,426 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 74 ms
71,300 KB |
testcase_01 | AC | 71 ms
71,584 KB |
testcase_02 | AC | 161 ms
102,076 KB |
testcase_03 | AC | 125 ms
101,716 KB |
testcase_04 | AC | 127 ms
100,160 KB |
testcase_05 | AC | 69 ms
71,536 KB |
testcase_06 | AC | 484 ms
99,976 KB |
testcase_07 | AC | 88 ms
76,936 KB |
testcase_08 | AC | 115 ms
79,584 KB |
testcase_09 | AC | 445 ms
100,560 KB |
testcase_10 | AC | 395 ms
99,632 KB |
testcase_11 | AC | 139 ms
80,248 KB |
testcase_12 | AC | 364 ms
99,604 KB |
testcase_13 | AC | 100 ms
76,776 KB |
testcase_14 | AC | 503 ms
100,212 KB |
testcase_15 | AC | 433 ms
99,588 KB |
testcase_16 | AC | 492 ms
100,084 KB |
testcase_17 | AC | 202 ms
97,300 KB |
testcase_18 | AC | 124 ms
89,304 KB |
testcase_19 | AC | 217 ms
86,460 KB |
testcase_20 | AC | 276 ms
91,108 KB |
ソースコード
# おっと有向辺だった # しかも1から全頂点にたどり着けるかという問題 # 完全に問題読み違えてた # Union Findでもない # 辺をソートして、1がなければ2にたどり着けない # 2までたどり着いたら、1か2がなければ3にたどり着けない # これを繰り返してNまで行ければYES # グラフ構築では、行先から辺の数を引けば起点が決まる N = int(input()) A = list(map(int, input().split())) A_with_idx = [] for i in range(N-1): A_with_idx.append([A[i], i]) A_with_idx.sort() ans = 'YES' for i in range(1, N): if A_with_idx[i-1][0] > i: ans = 'NO' break else: A_with_idx[i-1].append(i+1-A_with_idx[i-1][0]) A_with_idx.sort(key = lambda x:x[1]) #print(ans) #print(A_with_idx) if ans == 'NO': print(ans) else: print(ans) for a, b, c in A_with_idx: print(c)