QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#136373 | #82. Improve SPAM | Redex89 | WA | 39ms | 7756kb | C++23 | 1.7kb | 2023-08-08 07:26:21 | 2023-08-08 07:26:25 |
Judging History
answer
#include <bits/stdc++.h>
//Pura gente del coach moy
using namespace std;
#define ENDL '\n'
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(x) (int) x.size()
#define FOR(x, b) for(int x = 0; x <b; x++)
#define FORE(x, a, b) for(int x = a; x <= b; x++)
#define FORR(x, a, b) for(int x = a; x >= b; x--)
#define deb(x) cerr << #x << " = " << x << '\n';
#define deb2(x, y) cerr << #x << " = " << x << ", " << #y << " = " << y << '\n';
#define _ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
const ll MOD = 1e9+7, INF = 1e18;
vi adj[2100], ts;
bool visited[2100];
ll inDeg[2100];
ll ideal = 0, paths = 0;
void toposort(int u) {
visited[u] = 1;
for (auto v : adj[u])
if (!visited[v])
toposort(v);
ts.push_back(u);
}
int main(){_
int x, k, n, l;
cin >> n >> l;
FOR(i, l){
cin >> k;
FOR(j, k){
cin >> x;
x--;
adj[i].push_back(x);
}
}
FOR(u, n){
if(!visited[u])
toposort(u);
}
reverse(all(ts));
inDeg[0] = 1;
for(auto u : ts){
for(auto v : adj[u]){
inDeg[v] += inDeg[u];
inDeg[v] %= MOD;
}
}
ll ans1 = 0;
FORE(i, l, n - 1){
if(inDeg[i] > 0){
ideal++;
ideal %= MOD;
ans1 += inDeg[i];
ans1 %= MOD;
}
}
cout << ans1 << " " << ideal << ENDL;
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3528kb
input:
5 3 2 2 3 2 4 5 2 4 2
output:
5 2
result:
ok single line: '5 2'
Test #2:
score: 0
Accepted
time: 14ms
memory: 5340kb
input:
747 742 746 257 285 566 157 404 295 517 412 621 639 550 323 695 452 521 449 663 159 61 135 562 130 542 261 666 231 396 290 64 700 359 410 355 579 420 365 329 528 456 256 372 358 613 425 742 210 648 219 186 105 634 646 320 131 553 10 489 216 369 78 539 607 590 155 641 367 151 628 479 733 548 248 503 ...
output:
207670022 5
result:
ok single line: '207670022 5'
Test #3:
score: 0
Accepted
time: 0ms
memory: 4152kb
input:
414 387 413 56 229 232 325 44 19 406 239 397 272 172 231 242 260 321 362 171 199 315 142 360 290 228 387 51 86 382 395 324 151 150 21 412 176 105 237 278 318 183 92 355 76 63 160 385 12 157 319 196 100 143 274 103 174 213 269 36 139 249 117 314 93 336 189 30 399 45 70 289 361 115 38 187 394 161 267 ...
output:
737998792 27
result:
ok single line: '737998792 27'
Test #4:
score: 0
Accepted
time: 1ms
memory: 3688kb
input:
131 89 130 67 93 37 57 112 126 46 48 110 105 127 50 49 51 18 30 103 53 13 120 31 85 123 84 41 119 8 20 114 108 21 129 33 12 98 22 45 28 63 121 47 43 116 19 42 36 94 131 81 91 27 107 78 64 102 71 125 104 66 115 101 9 3 38 4 62 73 25 117 55 82 96 29 11 88 6 24 15 52 34 14 10 122 60 90 83 75 58 35 56 7...
output:
885499907 42
result:
ok single line: '885499907 42'
Test #5:
score: 0
Accepted
time: 1ms
memory: 3476kb
input:
100 90 99 15 19 32 78 83 33 77 96 6 84 25 12 54 50 89 90 51 27 60 92 7 80 52 8 5 10 47 46 22 55 81 29 17 59 13 72 73 69 61 99 57 68 44 93 63 9 58 43 16 45 26 95 100 65 86 74 56 62 75 24 18 71 49 28 76 64 40 4 14 70 88 34 35 20 53 30 2 82 87 23 97 39 98 41 91 66 38 42 36 67 3 48 31 85 21 79 94 11 37 ...
output:
802619006 10
result:
ok single line: '802619006 10'
Test #6:
score: 0
Accepted
time: 1ms
memory: 3528kb
input:
13 10 12 12 10 9 5 7 13 4 11 2 6 3 8 11 7 11 9 6 4 12 3 13 5 10 8 10 8 5 12 7 9 10 13 11 6 4 9 11 5 8 7 13 9 12 10 6 8 9 13 7 12 11 8 10 6 7 7 10 12 8 11 9 13 6 13 12 10 9 11 8 5 9 12 11 13 10 4 10 12 11 13 3 12 11 13
output:
1536 3
result:
ok single line: '1536 3'
Test #7:
score: 0
Accepted
time: 0ms
memory: 3532kb
input:
29 27 28 23 16 5 17 2 29 9 18 21 19 10 28 20 25 22 27 4 7 3 14 24 6 8 13 12 11 15 26 27 19 4 21 13 23 22 16 17 27 25 20 12 6 26 8 7 10 15 28 24 11 9 29 18 3 14 5 26 12 22 28 26 15 10 20 7 14 18 24 8 11 21 16 25 19 5 13 17 4 29 27 6 9 23 25 14 26 10 9 28 6 19 22 16 27 7 11 17 13 8 24 25 23 12 15 21 2...
output:
134217728 2
result:
ok single line: '134217728 2'
Test #8:
score: 0
Accepted
time: 39ms
memory: 7756kb
input:
2000 1000 1116 5 7 17 22 24 29 32 33 41 47 53 58 64 66 67 68 79 81 84 86 93 110 112 115 123 128 130 132 137 139 143 144 148 149 151 163 168 174 175 180 189 195 198 202 207 208 214 225 230 237 240 242 245 251 255 257 261 265 274 285 286 288 294 295 296 299 300 306 315 318 321 328 329 332 335 339 345 ...
output:
969365331 1000
result:
ok single line: '969365331 1000'
Test #9:
score: 0
Accepted
time: 38ms
memory: 7696kb
input:
1975 969 228 512 515 1028 598 8 10 526 16 17 1554 1555 532 1051 546 547 41 1067 557 48 888 562 566 57 570 571 1110 778 581 582 71 75 588 592 952 594 83 1108 597 86 88 90 603 529 105 103 622 623 112 626 632 124 638 641 642 107 132 134 651 652 144 280 146 707 431 151 665 1179 669 670 159 672 161 674 6...
output:
24972470 1006
result:
ok single line: '24972470 1006'
Test #10:
score: 0
Accepted
time: 7ms
memory: 4536kb
input:
1000 337 408 4 7 23 29 68 80 82 93 120 127 130 137 155 157 164 171 178 189 192 193 195 215 222 230 237 250 264 275 296 321 326 339 340 341 346 347 348 349 351 352 353 354 356 359 361 365 366 367 368 371 373 374 379 380 381 383 384 388 390 391 392 393 396 397 399 400 403 404 405 406 407 408 409 410 4...
output:
744521665 663
result:
ok single line: '744521665 663'
Test #11:
score: 0
Accepted
time: 6ms
memory: 4264kb
input:
1000 224 468 2 3 4 9 10 11 12 13 14 16 19 21 23 25 27 28 29 33 35 36 37 38 39 42 43 45 46 48 49 50 51 53 54 55 56 57 58 59 62 63 64 67 68 69 70 72 73 74 75 77 78 79 80 81 84 86 87 89 90 91 92 93 94 95 96 97 98 99 102 103 105 106 107 108 109 110 111 112 113 114 115 117 118 119 121 122 124 125 126 128...
output:
911119539 776
result:
ok single line: '911119539 776'
Test #12:
score: 0
Accepted
time: 1ms
memory: 3532kb
input:
15 6 1 6 7 10 11 12 13 9 7 8 5 6 14 4 5 15 2 14 15 2 4 14 2 5 4
output:
5 2
result:
ok single line: '5 2'
Test #13:
score: 0
Accepted
time: 3ms
memory: 3752kb
input:
1000 51 127 260 878 521 266 215 524 15 272 787 790 791 539 799 805 295 903 558 477 560 53 566 982 313 828 377 576 67 837 71 652 586 482 593 85 983 343 267 857 347 395 93 523 99 651 103 924 110 111 114 659 885 630 889 379 638 639 641 642 387 976 133 646 135 392 139 140 909 655 400 657 579 404 366 664...
output:
1020 903
result:
ok single line: '1020 903'
Test #14:
score: 0
Accepted
time: 1ms
memory: 3592kb
input:
1000 11 604 4 7 8 10 11 13 17 18 19 20 23 29 31 32 33 42 44 45 46 47 49 52 53 55 57 61 65 66 68 70 71 73 74 75 76 77 78 79 80 81 83 84 85 86 89 90 91 93 94 96 99 100 102 104 105 106 107 109 111 113 114 116 120 121 122 123 127 129 130 131 132 134 135 136 137 140 141 142 143 144 145 146 148 150 152 15...
output:
6768 989
result:
ok single line: '6768 989'
Test #15:
score: 0
Accepted
time: 1ms
memory: 3576kb
input:
1000 7 643 9 10 11 12 13 19 22 23 24 26 28 30 32 34 35 36 37 38 39 40 41 46 48 49 51 52 53 54 55 57 59 60 61 63 66 68 71 72 73 74 75 76 78 79 80 81 82 90 92 96 97 98 99 101 103 104 106 107 113 115 116 117 120 121 125 126 128 129 131 133 134 135 136 137 138 139 140 143 147 148 152 154 157 158 159 160...
output:
643 643
result:
ok single line: '643 643'
Test #16:
score: 0
Accepted
time: 0ms
memory: 3588kb
input:
2 1 1 2
output:
1 1
result:
ok single line: '1 1'
Test #17:
score: 0
Accepted
time: 1ms
memory: 3476kb
input:
3 1 2 2 3
output:
2 2
result:
ok single line: '2 2'
Test #18:
score: 0
Accepted
time: 1ms
memory: 3524kb
input:
5 2 3 2 4 5 3 3 4 5
output:
5 3
result:
ok single line: '5 3'
Test #19:
score: 0
Accepted
time: 1ms
memory: 3528kb
input:
8 2 4 8 3 4 6 5 8 1 4 5 7
output:
4 4
result:
ok single line: '4 4'
Test #20:
score: 0
Accepted
time: 1ms
memory: 3544kb
input:
13 3 6 2 3 6 7 10 11 9 4 5 7 8 9 10 11 12 13 10 4 5 6 7 8 9 10 11 12 13
output:
23 10
result:
ok single line: '23 10'
Test #21:
score: 0
Accepted
time: 1ms
memory: 3540kb
input:
21 3 10 21 20 5 7 9 10 12 13 14 15 16 1 4 5 6 8 9 10 11 12 13 14 15 16 18 19 20 18 1 2 4 5 7 8 9 10 11 12 13 14 15 16 17 18 19 20
output:
10 10
result:
ok single line: '10 10'
Test #22:
score: 0
Accepted
time: 1ms
memory: 3536kb
input:
34 4 19 4 6 7 8 9 10 11 12 14 19 23 24 26 28 29 30 31 32 33 28 1 5 6 7 8 9 10 12 13 14 15 16 17 19 21 22 23 24 25 26 27 28 29 30 31 32 33 34 29 5 6 7 8 9 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 7 33 8 11 12 13 29 30
output:
25 19
result:
ok single line: '25 19'
Test #23:
score: 0
Accepted
time: 1ms
memory: 3656kb
input:
10 5 4 8 9 10 3 3 9 10 6 3 8 9 7 6 2 3 6 7 8 10 5 9 10 3 1 7
output:
6 4
result:
ok single line: '6 4'
Test #24:
score: 0
Accepted
time: 0ms
memory: 3536kb
input:
55 4 51 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 34 5 7 8 11 12 13 14 17 18 21 22 23 25 27 28 29 30 32 33 35 37 38 39 40 42 43 44 46 47 48 49 50 53 54 17 1 2 5 7 11 14 18 22 25 26 34 37 38 43 4...
output:
51 51
result:
ok single line: '51 51'
Test #25:
score: 0
Accepted
time: 1ms
memory: 3532kb
input:
89 5 68 6 7 9 10 11 12 13 14 15 16 17 19 20 21 22 24 25 26 27 29 30 31 32 33 34 35 36 37 39 40 42 43 44 45 46 47 50 51 53 54 58 59 60 61 63 64 66 67 68 69 70 71 72 73 74 75 77 78 79 80 81 82 83 84 85 87 88 89 58 1 7 8 9 10 12 14 15 17 18 19 21 22 23 25 26 27 28 29 30 32 35 37 38 41 42 43 44 45 47 49...
output:
68 68
result:
ok single line: '68 68'
Test #26:
score: 0
Accepted
time: 1ms
memory: 3668kb
input:
144 5 102 6 7 9 10 11 13 14 16 17 18 19 20 22 23 24 25 26 27 28 29 30 31 32 34 35 38 39 40 41 42 44 46 50 51 52 53 54 55 58 59 60 64 65 66 68 69 70 72 74 75 78 79 80 81 83 86 87 89 90 92 93 94 95 96 97 98 99 100 102 103 104 105 108 109 110 111 112 113 115 117 118 120 122 123 124 125 126 127 129 130 ...
output:
102 102
result:
ok single line: '102 102'
Test #27:
score: -100
Wrong Answer
time: 0ms
memory: 3544kb
input:
64 63 16 61 59 57 43 39 33 31 27 23 21 15 13 11 7 5 3 2 4 5 2 4 5 2 6 7 2 6 7 2 8 9 2 8 9 2 10 11 2 10 11 2 12 13 2 12 13 2 14 15 2 14 15 2 16 17 2 16 17 2 18 19 2 18 19 2 20 21 2 20 21 2 22 23 2 22 23 2 24 25 2 24 25 2 26 27 2 26 27 2 28 29 2 28 29 2 30 31 2 30 31 2 32 33 2 32 33 2 34 35 2 34 35 2 ...
output:
0 0
result:
wrong answer 1st lines differ - expected: '0 1', found: '0 0'