Submission #826450

#TimeUsernameProblemLanguageResultExecution timeMemory
826450tolbiToy Train (IOI17_train)C++17
11 / 100
1180 ms1312 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); vector<bool> res(n,false); res[tar]=true; if (!r[tar]) continue; function<bool(int)> dfs; dfs = [&](int node)->bool{ if (vis[node]) return res[node]; vis[node]=true; int sz = 0; for (int i = 0; i < arr[node].size(); i++){ if (dfs(arr[node][i])) sz++; } if ((sz>=1 && a[node]) || sz==arr[node].size()) res[node]=true; return res[node]; }; int sz = 0; for (int j = 0; j < arr[tar].size(); j++){ if (dfs(arr[tar][j])) sz++; } if ((sz>=1 && a[tar]) || sz==arr[tar].size()) r[tar]=true; else r[tar]=false; } for (int iter = 0; iter < n; iter++){ 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:23:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   23 |    for (int i = 0; i < arr[node].size(); i++){
      |                    ~~^~~~~~~~~~~~~~~~~~
train.cpp:26:32: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |    if ((sz>=1 && a[node]) || sz==arr[node].size()) res[node]=true;
      |                              ~~^~~~~~~~~~~~~~~~~~
train.cpp: In function 'std::vector<int> who_wins(std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
train.cpp:30:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |   for (int j = 0; j < arr[tar].size(); j++){
      |                   ~~^~~~~~~~~~~~~~~~~
train.cpp:33:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |   if ((sz>=1 && a[tar]) || sz==arr[tar].size()) r[tar]=true;
      |                            ~~^~~~~~~~~~~~~~~~~
train.cpp:40:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   40 |    for (int i = 0; i < arr[node].size(); i++){
      |                    ~~^~~~~~~~~~~~~~~~~~
train.cpp:43:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   43 |    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...