結果
問題 | No.399 動的な領主 |
ユーザー | ghasshee |
提出日時 | 2016-07-16 14:54:22 |
言語 | C90 (gcc 11.4.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 941 bytes |
コンパイル時間 | 504 ms |
コンパイル使用メモリ | 21,504 KB |
実行使用メモリ | 10,496 KB |
最終ジャッジ日時 | 2024-10-15 13:45:51 |
合計ジャッジ時間 | 10,793 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | TLE | - |
testcase_01 | -- | - |
testcase_02 | -- | - |
testcase_03 | -- | - |
testcase_04 | -- | - |
testcase_05 | -- | - |
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 ‘tax’ defaults to ‘int’ [-Wimplicit-int] 24 | void pay(tax) { | ^~~ main.c: In function ‘search’: main.c:28:5: warning: type of ‘u’ defaults to ‘int’ [-Wimplicit-int] 28 | int search(u,v,parent) // @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: In function ‘main’: main.c:45:15: warning: format ‘%lld’ expects argument of type ‘long long int *’, but argument 2 has type ‘int *’ [-Wformat=] 45 | scanf("%lld", &n); | ~~~^ ~~ | | | | | int * | long long int * | %d main.c:48:19: warning: format ‘%lld’ expects argument of type ‘long long int *’, but argument 2 has type ‘int *’ [-Wformat=] 48 | scanf("%lld%lld", &u, &v); | ~~~^ ~~ | | | | | int * | long long int * | %d main.c:48:23: warning: format ‘%lld’ expects argument of type ‘long long int *’, but argument 3 has type ‘int *’ [-Wformat=] 48 | scanf("%lld%lld", &u, &v); | ~~~^ ~~ | | | | | int * | long long int * | %d main.c:52:15: warning: format ‘%lld’ expects argument of type ‘long long int *’, but argument 2 has type ‘int *’ [-Wformat=] 52 | scanf("%lld"
ソースコード
/* * 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; void push(u,v) { node[u][node[u][0]] = v; node[u][0]++; } void pay(tax) { taxsum += tax; } int search(u,v,parent) // @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 (parent == node[u][i]) continue; else if (node[u][i] == v) return ret; else ret += search(node[u][i],v,u); } pay(-(tax[u]--)); return 0; } int main(int argc, char** argv) { int i,n,u,v,q; scanf("%lld", &n); for (i=1; i <= n-1; i++) { scanf("%lld%lld", &u, &v); push(u,v); push(v,u); } scanf("%lld", &q); for (i=0; i<q; i++) { scanf("%lld%lld",&a[i],&b[i]); search(a[i],b[i],-1); } return taxsum; }