QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#515682 | #3805. Promotions | Bacily# | WA | 116ms | 105216kb | C++23 | 2.3kb | 2024-08-11 20:49:03 | 2024-08-11 20:49:04 |
Judging History
answer
#include <bits/stdc++.h>
#define lll __int128
#define el '\n'
#define sz(x) x.size()
using namespace std;
using ll = long long;
using ull = unsigned long long;
vector<vector<int>> adj, adj2;
vector<int> lvl;
int const N = 5e3;
bitset<N> bt[N];
vector<int> num(N + 1), szz(N + 1), vis(N + 1), par(N + 1);
int comps = 0;
void bfs(queue<int> &q, int n) {
for (int i = 0; i < n; i++)bt[i][i] = 1;
while (!q.empty()) {
int node = q.front();
q.pop();
for (auto child: adj[node]) {
bt[child] |= bt[node];
if (num[child] == 1) {
lvl[child] = lvl[node] + 1;
q.push(child);
}
num[child]--;
}
}
}
void dfs(int node, int pr) {
vis[node] = 1;
szz[pr]++;
par[node] = pr;
for (auto child: adj2[node]) {
if (vis[child])continue;
dfs(child, pr);
}
}
long long solverange(int mid, int n) {
long long ans = 0;
vector<vector<int>> freq(n + 1, vector<int>(n + 1));
for (int i = 0; i < n; i++) {
freq[par[i]][lvl[i]]++;
}
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
if (j)freq[i][j] += freq[i][j - 1];
}
}
for (int i = 0; i < n; i++) {
int rem = mid - (n - szz[par[i]]);
if (freq[par[i]][lvl[i]] <= rem)ans++;
}
return ans;
}
int solveD(int r, int n) {
int ans = 0;
for (int i = 0; i < n; i++) {
if (bt[i].count() > r)ans++;
}
return ans;
}
void tc() {
int l, r, n, m;
cin >> l >> r >> n >> m;
adj = vector<vector<int>>(n + 1);
adj2 = vector<vector<int>>(n + 1);
lvl = vector<int>(n + 1);
for (int i = 0; i < m; i++) {
int u, v;
cin >> u >> v;
adj[u].push_back(v);
adj2[u].push_back(v);
adj2[v].push_back(u);
num[v]++;
}
queue<int> q;
for (int i = 0; i < n; i++) {
if (!num[i]) q.push(i);
}
bfs(q, n);
for (int i = 0; i < n; i++) {
if (!vis[i])dfs(i, i), comps++;
}
cout << solverange(l, n) << el << solverange(r, n) << el << solveD(r, n) << '\n';
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
tc();
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3644kb
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: -100
Wrong Answer
time: 116ms
memory: 105216kb
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:
2897 3334 0
result:
wrong answer 1st lines differ - expected: '1', found: '2897'