제출 #167881

#제출 시각아이디문제언어결과실행 시간메모리
167881dolphingarlic장난감 기차 (IOI17_train)C++14
0 / 100
9 ms1404 KiB
#include "train.h" #include <bits/stdc++.h> #define FOR(i, x, y) for (int i = x; i < y; i++) using namespace std; vector<int> res, graph[3000]; bool arezou[3000], charging[3000], in_f[2][3000], visited[2][3000]; int f_cnt[2]; void dfs(int node, int step) { visited[step][node] = true; for (int i : graph[node]) { if (!visited[step][i]) dfs(i, step); in_f[step][node] |= in_f[step][i]; } if (in_f[step][node]) f_cnt[step]++; } void solve(vector<int> stations) { if (!stations.size()) return; for (int i : stations) visited[0][i] = visited[1][i] = in_f[0][i] = in_f[0][i] = false; f_cnt[0] = f_cnt[1] = 0; for (int i : stations) if (charging[i]) { visited[0][i] = in_f[0][i] = true; f_cnt[0]++; } for (int i : stations) if (!visited[0][i]) dfs(i, 0); if (f_cnt[0] == (int)stations.size()) { for (int i : stations) res[i] = true; return; } for (int i : stations) if (!in_f[0][i]) { visited[1][i] = in_f[1][i] = true; f_cnt[1]++; } for (int i : stations) if (!visited[1][i]) dfs(i, 1); if (f_cnt[1] == (int)stations.size()) return; vector<int> new_stations; for (int i : stations) if (!in_f[1][i]) new_stations.push_back(i); solve(new_stations); } vector<int> who_wins(vector<int> a, vector<int> r, vector<int> u, vector<int> v) { int n = a.size(), m = u.size(); res.resize(n); FOR(i, 0, m) graph[u[i]].push_back(v[i]); FOR(i, 0, n) arezou[i] = a[i], charging[i] = r[i]; vector<int> stations(n); FOR(i, 0, n) stations[i] = i; solve(stations); return res; }

컴파일 시 표준 에러 (stderr) 메시지

train.cpp: In function 'void solve(std::vector<int>)':
train.cpp:22:68: warning: operation on 'in_f[0][i]' may be undefined [-Wsequence-point]
  for (int i : stations) visited[0][i] = visited[1][i] = in_f[0][i] = in_f[0][i] = false;
                                                         ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~
#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...