Submission #783512

#TimeUsernameProblemLanguageResultExecution timeMemory
783512vjudge1Toy Train (IOI17_train)C++17
10 / 100
5 ms1492 KiB
#include "train.h"
#include<bits/stdc++.h>
using namespace std;
vector<int> a, adj[16], r, stkp(16);
int sz;
int dfs(int n, int last_C) {
    if(stkp[n])
        return last_C >= stkp[n];
    stkp[n] = ++sz;
    if(r[n]) {
        last_C = sz;
    }
    bool res = !a[n];
    for(auto i: adj[n])
        if(dfs(i, last_C)^res) {
            res^=1;
            break;
        }
    stkp[n] = 0;
    sz--;
    return res;
}
std::vector<int> who_wins(std::vector<int> A, std::vector<int> R, std::vector<int> u, std::vector<int> v) {
    a=A;
    r=R;
    for(int i = 0; i < u.size(); i++) {
        adj[u[i]].push_back(v[i]);
    }
    vector<int> res;
    for(int i = 0; i < A.size(); i++)
        res.push_back(dfs(i,-1));
	return res;
}

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:26:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |     for(int i = 0; i < u.size(); i++) {
      |                    ~~^~~~~~~~~~
train.cpp:30:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |     for(int i = 0; i < A.size(); i++)
      |                    ~~^~~~~~~~~~
train.cpp:30:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   30 |     for(int i = 0; i < A.size(); i++)
      |     ^~~
train.cpp:32:2: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   32 |  return res;
      |  ^~~~~~
#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...
#Verdict Execution timeMemoryGrader output
Fetching results...