結果
問題 | No.1888 Odd Insertion |
ユーザー | ygussany |
提出日時 | 2022-03-06 17:51:21 |
言語 | C (gcc 12.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,842 bytes |
コンパイル時間 | 536 ms |
コンパイル使用メモリ | 32,128 KB |
実行使用メモリ | 14,464 KB |
最終ジャッジ日時 | 2024-07-21 03:43:33 |
合計ジャッジ時間 | 21,739 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
6,816 KB |
testcase_01 | AC | 1 ms
6,944 KB |
testcase_02 | AC | 1 ms
6,944 KB |
testcase_03 | AC | 1 ms
6,940 KB |
testcase_04 | AC | 1 ms
6,944 KB |
testcase_05 | AC | 1 ms
6,940 KB |
testcase_06 | AC | 28 ms
6,940 KB |
testcase_07 | AC | 27 ms
6,944 KB |
testcase_08 | AC | 81 ms
12,032 KB |
testcase_09 | AC | 81 ms
12,416 KB |
testcase_10 | AC | 76 ms
10,240 KB |
testcase_11 | AC | 80 ms
12,388 KB |
testcase_12 | AC | 73 ms
10,224 KB |
testcase_13 | AC | 81 ms
11,904 KB |
testcase_14 | AC | 80 ms
12,416 KB |
testcase_15 | AC | 70 ms
9,196 KB |
testcase_16 | AC | 104 ms
11,264 KB |
testcase_17 | AC | 76 ms
10,240 KB |
testcase_18 | AC | 103 ms
11,368 KB |
testcase_19 | AC | 96 ms
11,520 KB |
testcase_20 | AC | 116 ms
9,856 KB |
testcase_21 | AC | 101 ms
12,032 KB |
testcase_22 | AC | 115 ms
9,600 KB |
testcase_23 | AC | 109 ms
11,904 KB |
testcase_24 | AC | 109 ms
11,880 KB |
testcase_25 | AC | 109 ms
11,884 KB |
testcase_26 | AC | 75 ms
14,464 KB |
testcase_27 | AC | 58 ms
6,940 KB |
testcase_28 | AC | 57 ms
6,944 KB |
testcase_29 | AC | 53 ms
10,368 KB |
testcase_30 | AC | 1,981 ms
10,368 KB |
testcase_31 | AC | 1,980 ms
6,940 KB |
testcase_32 | AC | 60 ms
6,944 KB |
testcase_33 | AC | 59 ms
6,944 KB |
testcase_34 | AC | 59 ms
6,944 KB |
testcase_35 | WA | - |
testcase_36 | WA | - |
testcase_37 | WA | - |
testcase_38 | WA | - |
コンパイルメッセージ
main.c: In function 'recursion': main.c:53:64: warning: passing argument 5 of 'recursion' from incompatible pointer type [-Wincompatible-pointer-types] 53 | if (recursion(N, i + 1, P_inv, BIT, ans[i-l+1]) != 0) return 1; | ^ | | | int * main.c:27:57: note: expected 'int (*)[2]' but argument is of type 'int *' 27 | int recursion(int N, int l, int P_inv[], int BIT[], int ans[][2]) | ~~~~^~~~~~~~ main.c: In function 'solve': main.c:71:47: warning: passing argument 5 of 'recursion' from incompatible pointer type [-Wincompatible-pointer-types] 71 | return recursion(N, 1, P_inv, BIT, ans[1]); | ^ | | | int * main.c:27:57: note: expected 'int (*)[2]' but argument is of type 'int *' 27 | int recursion(int N, int l, int P_inv[], int BIT[], int ans[][2]) | ~~~~^~~~~~~~
ソースコード
#include <stdio.h> #include <sys/time.h> void add_BIT(int N, int BIT[], int i, int k) { while (i <= N) { BIT[i] += k; i += (i & -i); } } int sum_BIT(int BIT[], int r) { int sum = 0; while (r > 0) { sum += BIT[r]; r -= (r & -r); } return sum; } struct timeval t; double beg, cur; int memo[200001]; int recursion(int N, int l, int P_inv[], int BIT[], int ans[][2]) { if (l > N) return 1; else if (memo[l] != 0) return 0; gettimeofday(&t, NULL); cur = t.tv_sec + (double)t.tv_usec / 1000000; if (cur - beg > 1.98) return 0; int i, k; for (i = l + 1; i <= N; i++) { k = sum_BIT(BIT, P_inv[i] - 1); if (k % 2 != 0) break; add_BIT(N, BIT, P_inv[i], 1); ans[i-l-1][0] = i; ans[i-l-1][1] = k + 1; } for (i--; i >= l; i--) { gettimeofday(&t, NULL); cur = t.tv_sec + (double)t.tv_usec / 1000000; if (cur - beg > 1.98) return 0; k = sum_BIT(BIT, P_inv[l] - 1); if (k % 2 == 0) { add_BIT(N, BIT, P_inv[l], 1); ans[i-l][0] = l; ans[i-l][1] = k + 1; if (recursion(N, i + 1, P_inv, BIT, ans[i-l+1]) != 0) return 1; add_BIT(N, BIT, P_inv[l], -1); } if (i > l) add_BIT(N, BIT, P_inv[i], -1); } memo[l] = -1; return 0; } int solve(int N, int P[], int ans[][2]) { static int i, P_inv[200001], BIT[200001]; for (i = 1; i <= N; i++) { P_inv[P[i]] = i; BIT[i] = 0; memo[i] = 0; } return recursion(N, 1, P_inv, BIT, ans[1]); } int main() { gettimeofday(&t, NULL); beg = t.tv_sec + (double)t.tv_usec / 1000000; int i, N, P[200001], ans[200001][2]; scanf("%d", &N); for (i = 1; i <= N; i++) scanf("%d", &(P[i])); if (solve(N, P, ans) == 0) printf("No\n"); else { printf("Yes\n"); for (i = 1; i <= N; i++) printf("%d %d\n", ans[i][0], ans[i][1]); } fflush(stdout); return 0; }