結果
問題 |
No.3280 Black-Tailed Gull vs Monster
|
ユーザー |
![]() |
提出日時 | 2025-09-27 13:22:43 |
言語 | C (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 54 ms / 2,000 ms |
コード長 | 1,321 bytes |
コンパイル時間 | 370 ms |
コンパイル使用メモリ | 27,340 KB |
実行使用メモリ | 7,720 KB |
最終ジャッジ日時 | 2025-09-27 13:22:46 |
合計ジャッジ時間 | 2,869 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 40 |
コンパイルメッセージ
main.c: In function ‘main’: main.c:62:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 62 | scanf("%d %d %d", &n, &x, &q); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ main.c:67:17: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 67 | scanf("%d", &m); | ^~~~~~~~~~~~~~~ main.c:69:25: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 69 | scanf("%d", &f[i]); | ^~~~~~~~~~~~~~~~~~
ソースコード
#include<stdio.h> int h[200005], l; int comp_h(int a, int b) { if (h[a] > h[b]) return 1; else return -1; } void swap_h(int a, int b) { int f = h[a]; h[a] = h[b]; h[b] = f; return; } void push(int ne) { h[l] = ne; int p = l++; for (; p > 0; p = (p - 1) / 2) if (comp_h((p - 1) / 2, p) > 0) swap_h((p - 1) / 2, p); return; } int pop() { swap_h(0, --l); int p = 0; for (;;) { if (2 * p + 2 < l) { if (comp_h(2 * p + 1, 2 * p + 2) > 0) { if (comp_h(p, 2 * p + 2) > 0) swap_h(p, 2 * p + 2); p = 2 * p + 2; } else { if (comp_h(p, 2 * p + 1) > 0) swap_h(p, 2 * p + 1); p = 2 * p + 1; } } else if (2 * p + 1 < l) { if (comp_h(p, 2 * p + 1) > 0) swap_h(p, 2 * p + 1); p = 2 * p + 1; } else break; } return h[l]; } int f[200005]; int main() { int n, x, q; scanf("%d %d %d", &n, &x, &q); int i, m; int ans = 0, v; for (; q > 0; q--) { scanf("%d", &m); for (i = 0; i < m; i++) scanf("%d", &f[i]); l = 0; for (i = 0; i < m; i++) push(f[i]); for (i = 0; i < m; i++) f[i] = pop(); v = 0; for (i = 1; i < m; i++) if (f[i - 1] == f[i]) v = 1; for (i = 0; i < m; i++) if (f[i] == x) v = 2; ans += v; } if (ans % 2 > 0) printf("%d.5\n", ans / 2); else printf("%d\n", ans / 2); return 0; }