結果

問題 No.399 動的な領主
ユーザー ghassheeghasshee
提出日時 2016-07-16 15:40:12
言語 C90
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,236 bytes
コンパイル時間 166 ms
コンパイル使用メモリ 21,760 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-23 13:45:18
合計ジャッジ時間 5,939 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 OLE -
testcase_05 OLE -
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]);
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~

ソースコード

diff #

/*
 * 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);
}
0