結果
| 問題 | No.3782 Synchronized Subsequences |
| コンテスト | |
| ユーザー |
kidodesu
|
| 提出日時 | 2026-10-30 22:13:36 |
| 言語 | PyPy3 (8.0.0 + ACL) |
| 結果 |
WA
不安定
|
| 実行時間 | - |
| コード長 | 750 bytes |
| 記録 | |
| コンパイル時間 | 106 ms |
| コンパイル使用メモリ | 63,884 KB |
| 実行使用メモリ | 90,668 KB |
| 最終ジャッジ日時 | 2026-10-30 22:13:57 |
| 合計ジャッジ時間 | 9,593 ms |
|
ジャッジサーバーID (参考情報) |
judge7_0 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | WA * 20 TLE * 1 -- * 19 |
ソースコード
def main():
n = int(input())
P = list(map(lambda x: int(x)-1, input().split()))
Q = list(map(lambda x: int(x)-1, input().split()))
x0 = 0
x1 = 0
for i in range(n-1):
if P[i] < P[i+1]:
x0 ^= 1<<i
else:
x1 ^= 1<<i
ans = 0
for s in range(n):
ss = 1<<s
dp = [ss] * n
for i in range(n):
for j in range(i+1, n):
if Q[i] < Q[j]:
dp[j] |= (dp[i] & x0) << 1
else:
dp[j] |= (dp[i] & x1) << 1
rep = 0
for i in range(n):
rep = max(rep, dp[i].bit_length())
ans = max(ans, rep-s)
return ans
for _ in range(int(input())):
print(main())
kidodesu