結果
問題 |
No.1425 Yet Another Cyclic Shifts Sorting
|
ユーザー |
![]() |
提出日時 | 2025-06-12 19:50:38 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 764 bytes |
コンパイル時間 | 208 ms |
コンパイル使用メモリ | 82,060 KB |
実行使用メモリ | 269,152 KB |
最終ジャッジ日時 | 2025-06-12 19:50:46 |
合計ジャッジ時間 | 6,741 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 25 TLE * 1 -- * 22 |
ソースコード
def main(): import sys input = sys.stdin.read data = input().split() n = int(data[0]) A = list(map(int, data[1:n+1])) B = sorted(A) if A == B: print(0) return m = n while m > 0 and A[m-1] == B[m-1]: m -= 1 if m == 0: print(1) return def is_rotation(a, b): if len(a) != len(b): return False if a == b: return True doubled = b + b for i in range(len(b)): if doubled[i:i+len(b)] == a: return True return False a_part = A[:m] b_part = B[:m] if is_rotation(a_part, b_part): print(1) else: print(2) if __name__ == "__main__": main()