QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#344888 | #3805. Promotions | PetroTarnavskyi# | AC ✓ | 90ms | 4420kb | C++20 | 1.2kb | 2024-03-05 17:24:35 | 2024-03-05 17:24:36 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define RFOR(i, a, b) for(int i = (a) - 1; i >= (b); i--)
#define SZ(a) int(a.size())
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair
#define F first
#define S second
typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;
typedef double db;
const int N = 5047;
VI g[N];
VI gr[N];
bool used[N];
int dfs1(int v)
{
used[v] = 1;
int cnt = 1;
for (auto to : g[v])
if (!used[to])
cnt += dfs1(to);
return cnt;
}
int dfs2(int v)
{
used[v] = 1;
int cnt = 1;
for (auto to : gr[v])
if (!used[to])
cnt += dfs2(to);
return cnt;
}
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
int a, b, n, m;
cin >> a >> b >> n >> m;
FOR (i, 0, m)
{
int u, v;
cin >> u >> v;
g[u].PB(v);
gr[v].PB(u);
}
VI ans(3);
FOR (i, 0, n)
{
fill(used, used + n, false);
int cnt = dfs1(i);
if (n - cnt < a)
ans[0]++;
if (n - cnt < b)
ans[1]++;
fill(used, used + n, false);
cnt = dfs2(i);
if (cnt > b)
ans[2]++;
}
cout << ans[0] << '\n' << ans[1] << '\n' << ans[2] << '\n';
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3500kb
input:
3 4 7 8 0 4 1 2 1 5 5 2 6 4 0 1 2 3 4 5
output:
2 4 3
result:
ok 3 lines
Test #2:
score: 0
Accepted
time: 37ms
memory: 4420kb
input:
3000 3500 5000 20000 1756 555 4733 3690 2912 2765 1233 1405 2822 1013 1664 4643 465 3265 3133 3063 2592 2060 2540 3030 209 2208 2708 3115 4839 463 9 3672 3446 2864 198 3985 1947 3892 1312 4255 130 485 3183 3653 1081 72 1730 3727 1017 1731 2494 4156 4826 2405 984 3653 4649 3164 929 4453 4163 4336 80 ...
output:
1 61 0
result:
ok 3 lines
Test #3:
score: 0
Accepted
time: 13ms
memory: 4152kb
input:
4500 4900 5000 20000 53 4538 1967 830 3525 772 3204 3440 4274 2480 882 679 1540 3537 4019 1929 3492 473 4317 2580 463 4847 2818 4215 3567 1713 1152 4668 1522 3140 185 4093 980 3310 1261 692 1500 2258 1826 4184 1825 1126 2930 4021 2749 2755 1886 1801 3618 1702 550 4255 4937 1756 727 1450 1391 3501 10...
output:
301 1021 0
result:
ok 3 lines
Test #4:
score: 0
Accepted
time: 13ms
memory: 4164kb
input:
1000 1001 5000 20000 3646 4993 56 2639 4779 4493 4462 4564 3390 1983 361 4578 2422 3007 4859 643 3123 4173 3308 2824 4532 4142 302 4848 3041 1326 1867 711 3331 1516 3046 4540 446 746 2903 912 3602 1946 3975 167 2919 2824 838 4570 4403 2074 2263 1053 957 1609 2134 199 1377 642 1161 2218 2159 410 3171...
output:
0 0 0
result:
ok 3 lines
Test #5:
score: 0
Accepted
time: 2ms
memory: 3876kb
input:
5 3126 3906 3905 0 1 0 2 0 3 0 4 0 5 1 6 1 7 1 8 1 9 1 10 2 11 2 12 2 13 2 14 2 15 3 16 3 17 3 18 3 19 3 20 4 21 4 22 4 23 4 24 4 25 5 26 5 27 5 28 5 29 5 30 6 31 6 32 6 33 6 34 6 35 7 36 7 37 7 38 7 39 7 40 8 41 8 42 8 43 8 44 8 45 9 46 9 47 9 48 9 49 9 50 10 51 10 52 10 53 10 54 10 55 11 56 11 57 ...
output:
1 6 0
result:
ok 3 lines
Test #6:
score: 0
Accepted
time: 1ms
memory: 4032kb
input:
5 3126 3907 3905 0 1 0 2 0 3 0 4 0 5 1 6 1 7 1 8 1 9 1 10 2 11 2 12 2 13 2 14 2 15 3 16 3 17 3 18 3 19 3 20 4 21 4 22 4 23 4 24 4 25 5 26 5 27 5 28 5 29 5 30 6 31 6 32 6 33 6 34 6 35 7 36 7 37 7 38 7 39 7 40 8 41 8 42 8 43 8 44 8 45 9 46 9 47 9 48 9 49 9 50 10 51 10 52 10 53 10 54 10 55 11 56 11 57 ...
output:
1 1 0
result:
ok 3 lines
Test #7:
score: 0
Accepted
time: 1ms
memory: 3828kb
input:
4 5 3907 3905 0 1 0 2 0 3 0 4 0 5 1 6 1 7 1 8 1 9 1 10 2 11 2 12 2 13 2 14 2 15 3 16 3 17 3 18 3 19 3 20 4 21 4 22 4 23 4 24 4 25 5 26 5 27 5 28 5 29 5 30 6 31 6 32 6 33 6 34 6 35 7 36 7 37 7 38 7 39 7 40 8 41 8 42 8 43 8 44 8 45 9 46 9 47 9 48 9 49 9 50 10 51 10 52 10 53 10 54 10 55 11 56 11 57 11 ...
output:
1 1 3125
result:
ok 3 lines
Test #8:
score: 0
Accepted
time: 4ms
memory: 4052kb
input:
50 70 200 19900 0 1 0 2 0 3 0 4 0 5 0 6 0 7 0 8 0 9 0 10 0 11 0 12 0 13 0 14 0 15 0 16 0 17 0 18 0 19 0 20 0 21 0 22 0 23 0 24 0 25 0 26 0 27 0 28 0 29 0 30 0 31 0 32 0 33 0 34 0 35 0 36 0 37 0 38 0 39 0 40 0 41 0 42 0 43 0 44 0 45 0 46 0 47 0 48 0 49 0 50 0 51 0 52 0 53 0 54 0 55 0 56 0 57 0 58 0 5...
output:
50 70 130
result:
ok 3 lines
Test #9:
score: 0
Accepted
time: 3ms
memory: 3860kb
input:
1 81 492 19926 0 1 0 2 0 3 0 4 0 5 0 6 0 7 0 8 0 9 0 10 0 11 0 12 0 13 0 14 0 15 0 16 0 17 0 18 0 19 0 20 0 21 0 22 0 23 0 24 0 25 0 26 0 27 0 28 0 29 0 30 0 31 0 32 0 33 0 34 0 35 0 36 0 37 0 38 0 39 0 40 0 41 0 42 0 43 0 44 0 45 0 46 0 47 0 48 0 49 0 50 0 51 0 52 0 53 0 54 0 55 0 56 0 57 0 58 0 59...
output:
0 0 6
result:
ok 3 lines
Test #10:
score: 0
Accepted
time: 3ms
memory: 3880kb
input:
100 142 282 19741 0 1 0 2 0 3 0 4 0 5 0 6 0 7 0 8 0 9 0 10 0 11 0 12 0 13 0 14 0 15 0 16 0 17 0 18 0 19 0 20 0 21 0 22 0 23 0 24 0 25 0 26 0 27 0 28 0 29 0 30 0 31 0 32 0 33 0 34 0 35 0 36 0 37 0 38 0 39 0 40 0 41 0 42 0 43 0 44 0 45 0 46 0 47 0 48 0 49 0 50 0 51 0 52 0 53 0 54 0 55 0 56 0 57 0 58 0...
output:
1 2 0
result:
ok 3 lines
Test #11:
score: 0
Accepted
time: 84ms
memory: 4264kb
input:
3490 3500 5000 20000 1631 3573 1208 2838 4697 1359 4374 1660 366 13 819 3697 4360 1271 577 3676 3077 433 4797 4580 595 1847 4092 744 3744 2710 3941 2904 3309 1752 3027 1578 3197 2671 2247 4313 1642 994 3124 1023 1172 1603 2818 352 3156 3999 4878 263 1428 2942 4878 3884 2564 2999 4598 4986 4631 3697 ...
output:
4 5 135
result:
ok 3 lines
Test #12:
score: 0
Accepted
time: 90ms
memory: 4268kb
input:
3400 3500 5000 20000 2617 140 3427 4796 2151 2114 1745 4524 1764 3388 290 4209 1714 2043 758 3061 2302 1563 1088 1760 466 105 2573 2113 1586 1479 1717 4215 224 1483 1287 2907 1163 4209 921 846 4093 2955 634 2705 788 802 4060 3240 3013 2826 3840 3698 3148 1604 559 660 142 2308 2764 4833 821 4264 3038...
output:
2 5 145
result:
ok 3 lines