Submission #826438

#TimeUsernameProblemLanguageResultExecution timeMemory
826438tolbiToy Train (IOI17_train)C++17
11 / 100
867 ms1424 KiB
#include <bits/stdc++.h> using namespace std; #include "train.h" std::vector<int> who_wins(std::vector<int> a, std::vector<int> r, std::vector<int> u, std::vector<int> v) { int n = a.size(); int m = u.size(); vector<vector<int>> arr(n); for (int i = 0; i < m; ++i) { arr[u[i]].push_back(v[i]); } for (int tar = 0; tar < n; tar++){ vector<bool> vis(n,false); if (!r[tar]) continue; function<void(int)> dfs; dfs = [&](int node)->void{ if (vis[node]) return; vis[node]=true; for (int i = 0; i < arr[node].size(); i++){ dfs(arr[node][i]); } }; for (int j = 0; j < arr[tar].size(); j++){ dfs(arr[tar][j]); } if (!vis[tar]) r[tar]=false; } for (int i = 0; i < n; i++){ for (int node = 0; node < n; node++){ if (r[node]) continue; int sz = 0; for (int i = 0; i < arr[node].size(); i++){ if (r[arr[node][i]]) sz++; } if ((a[node] && sz>0) || sz==arr[node].size()){ r[node]=1; break; } } } return r; }

Compilation message (stderr)

train.cpp: In lambda function:
train.cpp:20:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   20 |    for (int i = 0; i < arr[node].size(); i++){
      |                    ~~^~~~~~~~~~~~~~~~~~
train.cpp: In function 'std::vector<int> who_wins(std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
train.cpp:24:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 |   for (int j = 0; j < arr[tar].size(); j++){
      |                   ~~^~~~~~~~~~~~~~~~~
train.cpp:33:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |    for (int i = 0; i < arr[node].size(); i++){
      |                    ~~^~~~~~~~~~~~~~~~~~
train.cpp:36:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |    if ((a[node] && sz>0) || sz==arr[node].size()){
      |                             ~~^~~~~~~~~~~~~~~~~~
#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...