Submission #65505

#TimeUsernameProblemLanguageResultExecution timeMemory
65505gs13068Toy Train (IOI17_train)C++17
Compilation error
0 ms0 KiB
#include <vector>
using namespace std;
int d[2][5005], s[5005];
vector<int> g[5005];
vector<int> who_wins(vector<int> a, vector<int> r, vector<int> u, vector<int> v) {
int i, j, n = a.size(), m = u.size();
int *p = d[0], *q = d[1], *t;
for (i = 0; i < m; i++) g[u[i]].push_back(v[i]);
for (i = 0; i < n; i++) {
for (j = 0; j < n; j++) {
if (a[j] == 1) {
q[j] = 0;
for (auto t : g[j]) if (p[t] > q[j]) q[j] = p[t];
}
else {
q[j] = 1e9;
for (auto t : g[j]) if (p[t] < q[j]) q[j] = p[t];
}
if (r[j]) q[j]++;
}
t = p; p = q; q = t;
}
for (i = 0; i < n; i++) s[i] = p[i];
for (i = 0; i < n; i++) {
for (j = 0; j < n; j++) {
if (a[j] == 1) {
q[j] = 0;
for (auto t : g[j]) if (p[t] > q[j]) q[j] = p[t];
}
else {
q[j] = 1e9;
for (auto t : g[j]) if (p[t] < q[j]) q[j] = p[t];
}
if (r[j]) q[j]++;
}
t = p; p = q; q = t;
}
vector<int> ans;
for (i = 0; i < n; i++) ans.push_back(p[i] > s[i] ? 1 : 2)
return ans;
}

Compilation message (stderr)

train.cpp: In function 'std::vector<int> who_wins(std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
train.cpp:40:1: error: expected ';' before 'return'
 return ans;
 ^~~~~~
train.cpp:41:1: warning: no return statement in function returning non-void [-Wreturn-type]
 }
 ^