# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
227770 | AaronNaidu | 장난감 기차 (IOI17_train) | C++14 | 89 ms | 2048 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
vector<int> a, r, f;
vector<int> graph[6000];
vector<int> rgraph[6000];
vector<bool> visited;
int givesAWin[6000];
pair<bool, int> inCycle[6000];
vector<int> DFSpath;
vector<int> goodsInPath;
queue<int> q;
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) {
// cout << "Checking " << node << "\n";
if (inCycle[node].first and (goodsInPath.size() == 0 or inCycle[node].second > goodsInPath[goodsInPath.size() - 1]))
{
//cout << "In the cycle\n";
for (int i = 0; i < DFSpath.size(); i++)
{
//cout << DFSpath[i] << " gives a win\n";
if (!givesAWin[DFSpath[i]])
{
q.push(DFSpath[i]);
}
givesAWin[DFSpath[i]] = true;
}
//cout << "Leaving " << node << "\n";
return;
}
if (visited[node])
{
//cout << "Already visited\n";
if (givesAWin[node])
{
// cout << "Known to give a win\n";
for (auto i : DFSpath)
{
// cout << DFSpath[i] << " gives a win\n";
if (!givesAWin[i])
{
q.push(i);
}
givesAWin[i] = true;
}
}
// cout << "Leaving " << node << "\n";
return;
}
inCycle[node] = {true, DFSpath.size()};
if (r[node])
{
// cout << node << " is a charging station\n";
goodsInPath.push_back(DFSpath.size());
}
visited[node] = true;
DFSpath.push_back(node);
for (auto i : graph[node])
{
checkForCycle(i, starter, atStart);
}
inCycle[node].first = false;
DFSpath.pop_back();
if (r[node])
{
goodsInPath.pop_back();
}
// cout << "Leaving " << node << "\n";
}
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]);
rgraph[lv[i]].push_back(lu[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])
{
checkForCycle(i, i, true);
}
}
while (!q.empty())
{
int x = q.front();
q.pop();
for (auto i : rgraph[x])
{
if (!givesAWin[i])
{
givesAWin[i] = true;
q.push(i);
}
}
}
vector<int> toRet;
for (int i = 0; i < a.size(); i++)
{
toRet.push_back(!givesAWin[i]);
}
return toRet;
}
컴파일 시 표준 에러 (stderr) 메시지
# | 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... |