結果
問題 | No.399 動的な領主 |
ユーザー | ghasshee |
提出日時 | 2016-07-16 16:13:08 |
言語 | C90 (gcc 11.4.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,119 bytes |
コンパイル時間 | 149 ms |
コンパイル使用メモリ | 21,504 KB |
実行使用メモリ | 47,908 KB |
最終ジャッジ日時 | 2024-10-15 13:47:33 |
合計ジャッジ時間 | 3,914 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
10,496 KB |
testcase_01 | AC | 1 ms
5,248 KB |
testcase_02 | AC | 1 ms
5,248 KB |
testcase_03 | AC | 1 ms
5,248 KB |
testcase_04 | AC | 18 ms
5,248 KB |
testcase_05 | TLE | - |
testcase_06 | -- | - |
testcase_07 | -- | - |
testcase_08 | -- | - |
testcase_09 | -- | - |
testcase_10 | -- | - |
testcase_11 | -- | - |
testcase_12 | -- | - |
testcase_13 | -- | - |
testcase_14 | -- | - |
testcase_15 | -- | - |
testcase_16 | -- | - |
testcase_17 | -- | - |
testcase_18 | -- | - |
コンパイルメッセージ
main.c: In function ‘push’: main.c:19:6: warning: type of ‘u’ defaults to ‘int’ [-Wimplicit-int] 19 | void push(u,v) { | ^~~~ main.c:19:6: warning: type of ‘v’ defaults to ‘int’ [-Wimplicit-int] main.c: In function ‘pay’: main.c:24:6: warning: type of ‘t’ defaults to ‘int’ [-Wimplicit-int] 24 | void pay(t) { | ^~~ main.c: In function ‘search’: main.c:28:5: warning: type of ‘u’ defaults to ‘int’ [-Wimplicit-int] 28 | int search(u,v,parent,m) // @u search v -> returns the #edge between u,v | ^~~~~~ main.c:28:5: warning: type of ‘v’ defaults to ‘int’ [-Wimplicit-int] main.c:28:5: warning: type of ‘parent’ defaults to ‘int’ [-Wimplicit-int] main.c:28:5: warning: type of ‘m’ defaults to ‘int’ [-Wimplicit-int] main.c: In function ‘main’: main.c:52:5: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 52 | scanf("%d", &n); | ^~~~~~~~~~~~~~~ main.c:55:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 55 | scanf("%d%d", &u, &v); | ^~~~~~~~~~~~~~~~~~~~~ main.c:60:5: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 60 | scanf("%d", &q); | ^~~~~~~~~~~~~~~ main.c:63:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 63 | scanf("%d%d",&a[i],&b[i]); | ^~~~~~~~~~~~~~~~~~~~~~~~~
ソースコード
/* * N * u1 v1 * .. * un vn * Q : Q people * A1 B1 * .. * AQ BQ */ #include "stdio.h" int node[16384][16384]; int a[16384], b[16384], tax[16384]; int taxsum = 0; int COMPLETE = 0; void push(u,v) { ++node[u][0]; node[u][node[u][0]] = v; } void pay(t) { taxsum += t; } int search(u,v,parent,m) // @u search v -> returns the #edge between u,v { int i,ret=1; pay(++tax[u]); for (i=1;i<=node[u][0];i++){ if (COMPLETE) return ret; if (parent == node[u][i]) continue; else if (node[u][i] == v) { pay(++tax[v]); COMPLETE=1; return ret; } else ret += search(node[u][i],v,u,m); } if (COMPLETE) return ret; pay(-(tax[u]--)); return 0; } int main(int argc, char** argv) { int i,j,n,u,v,q; scanf("%d", &n); for (i=1; i <= n-1; i++) { scanf("%d%d", &u, &v); push(u,v); push(v,u); } scanf("%d", &q); for (i=0; i<q; i++) { scanf("%d%d",&a[i],&b[i]); COMPLETE=0; search(a[i],b[i],-1,i); } printf("%d\n",taxsum); }