제출 #226158

#제출 시각아이디문제언어결과실행 시간메모리
226158AaronNaiduSplit the Attractions (IOI19_split)C++14
18 / 100
118 ms12788 KiB
#include <bits/stdc++.h>
using namespace std;

vector<int> graph[100001];
int n, a, b, c, num;
bool visited[100001];
vector<int> toRet;

void dfs(int node) {
    visited[node] = true;
    if (num < a)
    {
        toRet[node] = 1;
    }
    else if (num < a + b)
    {
        toRet[node] = 2;
    }
    num++;
    for (auto i : graph[node])
    {
        if (!visited[i])
        {
            dfs(i);
        }
    }
}

vector<int> find_split(int ln, int la, int lb, int lc, vector<int> p, vector<int> q) {
    n = ln;
    a = la;
    b = lb;
    c = lc;
    for (int i = 0; i < p.size(); i++)
    {
        graph[p[i]].push_back(q[i]);
        graph[q[i]].push_back(p[i]);
    }
    for (int i = 0; i < n; i++)
    {
        toRet.push_back(3);
    }
    num = 0;
    bool found = false;
    for (int i = 0; i < n; i++)
    {
        if (graph[i].size() == 1)
        {
            dfs(i);
            found = true;
            break;
        }
    }
    if (!found)
    {
        dfs(0);
    }
    return toRet;
}

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

split.cpp: In function 'std::vector<int> find_split(int, int, int, int, std::vector<int>, std::vector<int>)':
split.cpp:34:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i = 0; i < p.size(); i++)
                     ~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...