제출 #253701

#제출 시각아이디문제언어결과실행 시간메모리
253701ErkhemkhuuSplit the Attractions (IOI19_split)C++17
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
const ll N = 100005;
vector <ll> path, path1;
bool vis[N];
vector <vector <ll> > adj(N);
ll need1, need2;
void dfs(ll v, ll cur) {
    path.pb(v);
    if(cur == need1 + 1) return;
    vis[v] = true;
    for(auto &u: adj[v]) {
        if(vis[u]) continue;
        dfs(u, cur + 1);
    }
    return;
}
void dfs1(ll v, ll cur) {
    path1.pb(v);
    if(cur == need2 + 1) return;
    vis[v] = true;
    for(auto &u: adj[v]) {
        if(vis[u]) continue;
        dfs1(u, cur + 1);
    }
    return;
}
void find_split(int n, int a, int b, int c, vector <ll> p, vector <ll> q) {
    ll m = p.size();
    for(i = 0; i < m; i++) {
        adj[p[i]].pb(q[i]);
        adj[q[i]].pb(p[i]);
    }
    vector <ll> vc;
    vc = {a, b, c};
    sort(vc.begin(), vc.end());
    need1 = vc[0];
    need2 = vc[1];
    dfs(0, 1);
    for(i = n - 1; i >= 1; i--) {
        if(!vis[i]) {
            dfs1(i, 1);
            break;
        }
    }
    vector <ll> ans(n, 0);
    for(auto &x: path)
        ans[x] = 1;
    for(auto &x: path1)
        ans[x] = 2;
    for(i = 0; i < n; i++)
        if(!vis[i]) ans[i] = 3;
    return ans;
}

컴파일 시 표준 에러 (stderr) 메시지

split.cpp: In function 'void find_split(int, int, int, int, std::vector<long long int>, std::vector<long long int>)':
split.cpp:35:9: error: 'i' was not declared in this scope
     for(i = 0; i < m; i++) {
         ^
split.cpp:45:9: error: 'i' was not declared in this scope
     for(i = n - 1; i >= 1; i--) {
         ^
split.cpp:56:9: error: 'i' was not declared in this scope
     for(i = 0; i < n; i++)
         ^
split.cpp:58:12: error: return-statement with a value, in function returning 'void' [-fpermissive]
     return ans;
            ^~~