QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#878069#9910. 颠倒歌Chenly0 5ms4096kbC++201.4kb2025-02-01 13:23:292025-02-01 13:23:35

Judging History

This is the latest submission verdict.

  • [2025-02-01 13:23:35]
  • Judged
  • Verdict: 0
  • Time: 5ms
  • Memory: 4096kb
  • [2025-02-01 13:23:29]
  • Submitted

answer

// #define NDEBUG
#include<bits/stdc++.h>
#define For(i,j,k) for(int i=(j);i<=(k);i++)
#define ForD(i,j,k) for(int i=(j);i>=(k);i--)
#define int long long
#define endl '\n'
using namespace std;
bool Mbe;
const int N=5e3+5,K=1e3+5,mod=998244353,i2=(mod+1)>>1;
int qpow(int a,int b){
    int ans=1;
    while(b){
        if(b&1) ans=ans*a%mod;
        a=a*a%mod; b>>=1;
    }
    return ans;
}
int p,k,n;
#define pb push_back
struct Tree{
    vector<int> E[N];
    void in(){
        For(i,1,n-1){
            int u,v; cin>>u>>v;
            E[u].pb(v),E[v].pb(u);
        }
    }
    int dfs(int u,int fa,int d){
        if((int)E[u].size()!=2) return qpow(d,d-2);
        for(int v:E[u]) if(v!=fa) return dfs(v,u,d+1);
    }
    int work(){
        int ans=1;
        For(i,1,n) if((int)E[i].size()!=2) for(int v:E[i]) ans=ans*dfs(v,i,2)%mod;
        return ans*i2%mod;
    }
}Tr[K];

void solve(){
    cin>>p>>k>>n;
    For(i,1,k) Tr[i].in();
    if(p==1){
        cout<<Tr[1].work()<<endl;
    }else{
        cout<<0<<endl;
    }
}
bool Med;
signed main(){
    fprintf(stderr,"%.3lf MB\n",(&Mbe-&Med)/1048576.0);
    // freopen("1.in","r",stdin), freopen("1.out","w",stdout);
    ios::sync_with_stdio(false); cin.tie(0),cout.tie(0);
    int _=1;
    // cin>>_;
    while(_--) solve();
    cerr<<1e3*clock()/CLOCKS_PER_SEC<<" ms\n";
    return 0;
}

詳細信息

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 5ms
memory: 4096kb

input:

1
4 7
1 7
4 1
2 3
2 6
5 4
7 2
5 7
7 3
1 2
4 1
4 3
5 6
5 4
2 4
3 5
7 2
2 6
1 7
1 7
6 4
5 2
3 6
3 1
4 5

output:

499129989

result:

wrong answer 1st lines differ - expected: '9', found: '499129989'

Subtask #2:

score: 0
Wrong Answer

Test #5:

score: 0
Wrong Answer
time: 5ms
memory: 3968kb

input:

0
1 189
77 175
145 175
4 175
92 175
175 33
175 125
175 185
157 175
186 175
115 175
113 175
38 175
175 138
175 133
175 48
175 128
175 66
175 34
175 148
150 175
175 104
175 84
175 59
175 154
80 175
176 175
135 175
55 175
139 175
175 132
175 91
13 175
175 110
155 175
175 60
175 184
73 175
152 175
83 17...

output:

0

result:

wrong answer 1st lines differ - expected: '5245226', found: '0'

Subtask #3:

score: 0
Skipped

Dependency #2:

0%

Subtask #4:

score: 0
Skipped

Dependency #3:

0%

Subtask #5:

score: 0
Skipped

Dependency #4:

0%

Subtask #6:

score: 0
Skipped

Dependency #5:

0%

Subtask #7:

score: 0
Wrong Answer

Test #25:

score: 0
Wrong Answer
time: 5ms
memory: 3968kb

input:

1
1 156
69 74
65 126
110 16
134 129
3 22
78 5
140 23
53 138
109 67
82 74
42 57
23 143
12 112
7 13
154 105
100 118
63 28
41 37
145 25
80 142
111 148
81 85
133 13
104 89
83 14
39 24
120 97
98 131
94 55
107 91
38 130
122 36
2 32
82 94
35 49
40 108
68 146
101 130
101 76
105 58
80 137
152 87
78 66
32 55
...

output:

973510680

result:

wrong answer 1st lines differ - expected: '261947439', found: '973510680'

Subtask #8:

score: 0
Skipped

Dependency #7:

0%

Subtask #9:

score: 0
Skipped

Dependency #8:

0%

Subtask #10:

score: 0
Skipped

Dependency #9:

0%

Subtask #11:

score: 0
Skipped

Dependency #10:

0%