이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
vector<int> a, r, f;
vector<int> graph[6000];
vector<bool> visited;
int givesAWin[6000];
vector<int> DFSpath;
bool cycleTime(int node, int orig) {
if (r[node])
{
return true;
}
if (node == orig)
{
return false;
}
return cycleTime(f[node], orig);
}
void checkForCycle(int node, int starter, bool atStart) {
if (atStart)
{
visited[node] = true;
DFSpath.push_back(node);
for (auto i : graph[node])
{
checkForCycle(i, starter, false);
}
DFSpath.pop_back();
return;
}
if (node == starter)
{
for (auto i : DFSpath)
{
givesAWin[i] = true;
}
}
if (visited[node])
{
return;
}
visited[node] = true;
DFSpath.push_back(node);
for (auto i : graph[node])
{
checkForCycle(i, starter, atStart);
}
DFSpath.pop_back();
}
vector<int> who_wins(vector<int> la, vector<int> lr, vector<int> lu, vector<int> lv) {
a = la;
r = lr;
for (int i = 0; i < lu.size(); i++)
{
graph[lu[i]].push_back(lv[i]);
}
for (int i = 0; i < a.size(); i++)
{
f.push_back(-1);
visited.push_back(false);
}
for (int i = 0; i < r.size(); i++)
{
if (r[i] == 1)
{
for (int j = 0; j < visited.size(); j++)
{
visited[j] = false;
}
checkForCycle(r[i], r[i], true);
}
}
vector<int> toRet;
for (int i = 0; i < a.size(); i++)
{
toRet.push_back(givesAWin[i]);
}
return toRet;
}
컴파일 시 표준 에러 (stderr) 메시지
train.cpp: In function 'std::vector<int> who_wins(std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
train.cpp:59:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int i = 0; i < lu.size(); i++)
~~^~~~~~~~~~~
train.cpp:63:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int i = 0; i < a.size(); i++)
~~^~~~~~~~~~
train.cpp:68:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int i = 0; i < r.size(); i++)
~~^~~~~~~~~~
train.cpp:72:31: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int j = 0; j < visited.size(); j++)
~~^~~~~~~~~~~~~~~~
train.cpp:81:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int i = 0; i < a.size(); i++)
~~^~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |