QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#878077 | #9910. 颠倒歌 | Chenly | 14 | 5ms | 4096kb | C++20 | 1.4kb | 2025-02-01 13:25:40 | 2025-02-01 13:25:40 |
Judging History
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,int b){
if((int)E[u].size()!=2){
if(u>b) return qpow(d,d-2);
else return 1;
}
for(int v:E[u]) if(v!=fa) return dfs(v,u,d+1,b);
}
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,i)%mod;
return ans;
}
}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: 3968kb
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:
125
result:
wrong answer 1st lines differ - expected: '9', found: '125'
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: 7
Accepted
Test #25:
score: 7
Accepted
time: 4ms
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:
261947439
result:
ok single line: '261947439'
Test #26:
score: 7
Accepted
time: 3ms
memory: 3840kb
input:
1 1 168 140 135 69 51 33 66 138 48 168 90 102 43 137 98 117 21 88 131 29 14 117 157 77 78 85 88 119 32 114 68 55 67 160 166 12 149 155 85 20 113 132 149 131 19 97 139 22 78 16 157 151 143 99 156 159 71 72 119 161 163 68 28 101 89 27 133 96 146 125 44 151 24 14 114 116 111 89 25 115 138 46 1 51 47 40...
output:
260505142
result:
ok single line: '260505142'
Test #27:
score: 7
Accepted
time: 4ms
memory: 4096kb
input:
1 1 155 77 28 89 81 138 11 85 7 124 53 29 52 116 32 151 66 103 80 145 77 82 51 116 138 141 144 57 20 34 101 14 84 75 68 42 64 95 117 117 137 122 33 76 50 12 71 112 44 134 83 134 18 105 10 75 122 106 94 84 69 1 123 140 10 70 71 78 133 24 152 87 13 9 31 135 142 101 146 149 129 28 16 52 39 26 119 146 3...
output:
252700555
result:
ok single line: '252700555'
Test #28:
score: 7
Accepted
time: 3ms
memory: 3968kb
input:
1 1 200 24 110 97 182 163 183 115 67 21 193 168 118 88 19 10 150 33 76 15 184 138 131 166 143 151 167 17 60 188 92 110 33 9 65 186 74 198 170 144 161 69 134 179 189 191 70 64 79 10 84 65 107 66 149 123 191 184 141 107 30 170 129 159 186 108 132 17 68 46 198 158 41 13 55 101 59 20 72 200 63 128 23 89...
output:
85910356
result:
ok single line: '85910356'
Subtask #8:
score: 7
Accepted
Dependency #7:
100%
Accepted
Test #29:
score: 7
Accepted
time: 4ms
memory: 3968kb
input:
1 1 170 104 123 43 65 8 61 169 138 20 160 34 169 133 25 129 2 115 137 64 168 33 35 77 38 128 166 159 151 78 3 155 34 6 140 16 133 26 117 13 143 144 150 7 131 64 61 162 52 149 16 17 80 136 77 141 83 54 146 85 47 140 24 107 158 91 152 66 43 24 21 86 38 141 85 51 11 162 151 2 66 73 74 9 26 156 68 121 1...
output:
83894725
result:
ok single line: '83894725'
Test #30:
score: 7
Accepted
time: 3ms
memory: 3968kb
input:
1 1 168 46 92 25 154 91 121 21 31 100 152 24 35 115 67 139 111 113 90 88 69 134 83 127 120 74 23 22 108 28 18 58 36 15 125 100 167 3 127 112 34 7 25 3 23 40 13 29 138 124 118 33 143 8 32 17 58 20 120 12 148 158 130 115 122 26 29 90 157 111 73 57 64 79 80 153 159 89 73 50 79 62 105 109 135 96 32 27 1...
output:
314954106
result:
ok single line: '314954106'
Test #31:
score: 7
Accepted
time: 5ms
memory: 3968kb
input:
1 1 173 71 145 155 153 150 80 164 52 158 173 116 96 169 100 59 20 143 151 43 73 66 38 77 161 39 91 166 11 35 136 4 145 65 37 163 67 138 140 170 31 28 124 85 104 27 2 50 129 76 82 69 155 36 33 86 112 58 23 89 40 47 3 64 27 94 110 36 22 47 67 99 19 165 134 55 131 16 118 68 144 45 53 52 35 125 6 120 77...
output:
223769237
result:
ok single line: '223769237'
Test #32:
score: 7
Accepted
time: 4ms
memory: 3968kb
input:
1 1 200 14 29 23 169 138 142 67 145 166 102 126 183 108 69 170 70 85 194 79 132 174 154 30 130 133 21 93 86 68 183 83 168 160 114 4 94 33 11 109 16 98 18 115 27 52 146 88 103 54 7 49 158 121 110 159 55 190 177 193 85 63 8 155 140 43 117 149 93 169 48 125 133 180 95 189 199 78 162 24 144 84 5 135 39 ...
output:
792535599
result:
ok single line: '792535599'
Subtask #9:
score: 0
Wrong Answer
Dependency #8:
100%
Accepted
Test #33:
score: 0
Wrong Answer
time: 4ms
memory: 4096kb
input:
1 2 160 85 103 57 106 55 79 43 92 96 116 100 68 93 88 103 24 70 144 7 12 142 123 95 77 134 15 16 153 98 74 8 150 56 142 47 58 91 54 65 59 77 131 101 47 17 8 10 5 61 97 89 115 46 96 92 36 43 34 159 139 73 28 66 151 44 76 18 13 33 76 127 67 4 33 9 102 126 9 133 141 88 109 32 27 50 117 128 140 126 10 7...
output:
418485450
result:
wrong answer 1st lines differ - expected: '138251585', found: '418485450'
Subtask #10:
score: 0
Skipped
Dependency #9:
0%
Subtask #11:
score: 0
Skipped
Dependency #10:
0%