Submission #122569

#TimeUsernameProblemLanguageResultExecution timeMemory
122569SirCenessToy Train (IOI17_train)C++14
5 / 100
2066 ms30032 KiB
#include <bits/stdc++.h> #define pb push_back #define mp make_pair using namespace std; typedef long long ll; list<int> adj[5003]; int sonuc[5003]; vector<int> a, r, u, v; set<int> byendi; int f(int node, set<int> barz){ //cout << "f(" << node << ")" << endl; if (sonuc[node] != 0){ if (sonuc[node] == 1) return 1; else { if (barz.find(node) == barz.end()) return 1; else return -1; } } if (r[node]){ sonuc[node] = 1; barz = byendi; } else { sonuc[node] = -1; barz.insert(node); } int ans = a[node] ? -1 : 1; for (list<int>::iterator it = adj[node].begin(); it != adj[node].end(); ++it){ if (*it == node) continue; if (a[node]) ans = max(ans, f(*it, barz)); else ans = min(ans, f(*it, barz)); } sonuc[node] = 0; return ans; } vector<int> who_wins(vector<int> A, vector<int> R, vector<int> U, vector<int> V) { a = A; r = R; u = U; v = V; for (int i = 0; i < u.size(); i++){ adj[u[i]].pb(v[i]); } vector<int> ans(a.size()); for (int i = 0; i < a.size(); i++) sonuc[i] = 0; for (int i = 0; i < a.size(); i++){ int kendi = 0; int baska = 0; for (list<int>::iterator it = adj[i].begin(); it != adj[i].end(); ++it){ if (*it == i) kendi = 1; else baska = 1; } if (kendi){ if (a[i] && r[i]) sonuc[i] = 1; else if (!a[i] && !r[i]) sonuc[i] = -1, byendi.insert(i); } if (!baska){ if (r[i]) sonuc[i] = 1; else sonuc[i] = -1, byendi.insert(i); } } for (int i = 0; i < a.size(); i++){ if (sonuc[i] == 0){ sonuc[i] = f(i, byendi); } } //for (int i = 0; i < a.size(); i++) cout << sonuc[i] << " "; cout << endl; for (int i = 0; i < a.size(); i++) ans[i] = (sonuc[i] == 1) ? 1 : 0; 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:45:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (int i = 0; i < u.size(); i++){
                  ~~^~~~~~~~~~
train.cpp:49:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (int i = 0; i < a.size(); i++) sonuc[i] = 0;
                  ~~^~~~~~~~~~
train.cpp:50:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (int i = 0; i < a.size(); i++){
                  ~~^~~~~~~~~~
train.cpp:66:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (int i = 0; i < a.size(); i++){
                  ~~^~~~~~~~~~
train.cpp:72:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (int i = 0; i < a.size(); i++) ans[i] = (sonuc[i] == 1) ? 1 : 0;
                  ~~^~~~~~~~~~
#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...