QOJ.ac
QOJ
The 2nd Universal Cup Finals is coming! Check out our event page, schedule, and competition rules!
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#796162 | #8212. Football in Osijek | ucup-team173# | Compile Error | / | / | C++23 | 1.8kb | 2024-12-01 13:33:07 | 2024-12-01 13:33:07 |
Judging History
This is the latest submission verdict.
- [2024-12-01 13:33:07]
- Judged
- Verdict: Compile Error
- Time: 0ms
- Memory: 0kb
- [2024-12-01 13:33:07]
- Submitted
answer
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
void solve() {
int n;
cin >> n;
vector<int> a(n + 1);
for(int i = 1; i <= n; i++) {
cin >> a[i];
}
vector<int> vis(n + 1), bel(n + 1), sz(n + 1), cir(n + 1);
vector<int> stk(n + 1), instk(n + 1); int tp = 0;
for(int i = 1; i <= n; i++) if(!vis[i]) {
auto dfs = [&](this auto &&self, int x) -> void {
vis[x] = 1, stk[++tp] = x, instk[x] = 1;
if(bel[a[x]]) {
bel[x] = bel[a[x]], sz[bel[x]]++;
} else if(vis[a[x]]) {
while(stk[tp] != a[x]) {
cir[x]++, sz[x]++;
bel[stk[tp]] = x;
instk[stk[tp]] = 0;
tp--;
}
cir[x]++, sz[x]++, bel[a[x]] = x, instk[a[x]] = 0, tp--;
} else {
self(a[x]);
}
if(instk[x]) tp--, instk[x] = 0;
};
dfs(i);
}
vector<int> ve, ans(n + 2);
for(int i = 1; i <= n; i++) {
if(bel[i] == i) {
ve.push_back(sz[i]);
ans[cir[i]]++, ans[sz[i] + 1]--;
}
}
for(int i = 1; i <= n; i++) ans[i] += ans[i - 1];
for(int i = 1; i <= n; i++) ans[i] = !ans[i];
sort(ve.begin(), ve.end(), greater<int>());
for(int i = 1; i < ve.size(); i++) ve[i] += ve[i - 1];
for(int i = 1; i < ve.size(); i++) {
for(int j = ve[i - 1] + 1; j <= ve[i]; j++) {
ans[j] = i;
}
}
for(int i = 1; i <= n; i++) {
cout << ans[i] << " \n"[i == n];
}
}
signed main() {
ios::sync_with_stdio(false);
cin.tie(0), cout.tie(0);
int t = 1;
// cin >> t;
while(t--) solve();
return 0;
}
详细
answer.code: In function ‘void solve()’: answer.code:16:24: error: expected identifier before ‘this’ 16 | auto dfs = [&](this auto &&self, int x) -> void { | ^~~~ answer.code:16:24: error: expected ‘,’ or ‘...’ before ‘this’ answer.code: In lambda function: answer.code:17:17: error: ‘x’ was not declared in this scope 17 | vis[x] = 1, stk[++tp] = x, instk[x] = 1; | ^ answer.code:29:17: error: ‘self’ was not declared in this scope 29 | self(a[x]); | ^~~~