結果
問題 | No.399 動的な領主 |
ユーザー | ghasshee |
提出日時 | 2016-07-16 15:41:39 |
言語 | C90 (gcc 11.4.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,250 bytes |
コンパイル時間 | 195 ms |
コンパイル使用メモリ | 21,376 KB |
実行使用メモリ | 46,336 KB |
最終ジャッジ日時 | 2024-10-15 13:46:57 |
合計ジャッジ時間 | 3,935 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 0 ms
10,496 KB |
testcase_01 | WA | - |
testcase_02 | WA | - |
testcase_03 | WA | - |
testcase_04 | WA | - |
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:49:5: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 49 | scanf("%d", &n); | ^~~~~~~~~~~~~~~ main.c:52:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 52 | scanf("%d%d", &u, &v); | ^~~~~~~~~~~~~~~~~~~~~ main.c:62:5: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 62 | scanf("%d", &q); | ^~~~~~~~~~~~~~~ main.c:65:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 65 | 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; 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++){ //printf("now marchant %d is in village %d and the tax is %d. the sum of tax is %d\n",m,u,tax[u],taxsum); if (parent == node[u][i]) continue; else if (node[u][i] == v) { pay(++tax[v]); return ret; } else ret += search(node[u][i],v,u,m); } 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); } //for (i=1;i<=n;i++) //{ // for (j=1;j<=node[i][0];j++) // printf("%d ", node[i][j]); // printf("\n"); //} scanf("%d", &q); for (i=0; i<q; i++) { scanf("%d%d",&a[i],&b[i]); search(a[i],b[i],-1,i); } printf("%d\n",taxsum); }