제출 #288991

#제출 시각아이디문제언어결과실행 시간메모리
288991AlexLuchianovToy Train (IOI17_train)C++14
0 / 100
12 ms1664 KiB
#include "train.h" #include <queue> #include <iostream> std::vector<std::vector<int>> g, depend; int refresh(int node, std::vector<int> &own, std::vector<int> &state) { if(own[node] == 1) { for(int h = 0; h < g[node].size();h ++) { int to = g[node][h]; if(state[to] == 1) return 1; } return 0; } else { for(int h = 0; h < g[node].size(); h++) { int to = g[node][h]; if(state[to] == 0) return 0; } return 1; } } std::vector<int> first_phase(std::vector<int> own, std::vector<int> r) { int n = own.size(); std::vector<int> state(n); std::queue<int> q; for(int i = 0; i < n; i++) if(r[i] == 1) { state[i] = 1; q.push(state[i]); } while(0 < q.size()) { int node = q.front(); q.pop(); for(int h = 0; h < depend[node].size(); h++) { int to = depend[node][h]; if(state[to] == 0) { state[to] = refresh(to, own, state); if(state[to] == 1) q.push(to); } } } return state; } int refresh2(int node, std::vector<int> &own, std::vector<int> &state) { if(own[node] == 1) { for(int h = 0; h < g[node].size(); h++) { int to = g[node][h]; if(state[to] == 0) return 0; } return 1; } else { for(int h = 0; h < g[node].size(); h++) { int to = g[node][h]; if(state[to] == 1) return 1; } return 0; } } std::vector<int> second_phase(std::vector<int> &own, std::vector<int> &init) { int n = own.size(); std::vector<int> state(own.size()); std::queue<int> q; for(int i = 0; i < n; i++) if(init[i] == 0) { state[i] = 1; q.push(i); } while(0 < q.size()) { int node = q.front(); q.pop(); for(int h = 0; h < depend[node].size(); h++) { int to = depend[node][h]; if(state[to] == 0) { state[to] == refresh2(to, own, state); if(state[to] == 1) { q.push(to); } } } } return state; } std::vector<int> who_wins(std::vector<int> a, std::vector<int> r, std::vector<int> u, std::vector<int> v) { std::vector<int> res(a.size()); int n = a.size(); g.resize(n); depend.resize(n); for(int i = 0; i < u.size(); i++) { g[u[i]].push_back(v[i]); depend[v[i]].push_back(u[i]); } std::vector<int> state = first_phase(a, r); std::vector<int> state2 = second_phase(a, state); for(int i = 0; i < n; i++) res[i] = !state2[i]; return res; }

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

train.cpp: In function 'int refresh(int, std::vector<int>&, std::vector<int>&)':
train.cpp:9:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    9 |     for(int h = 0; h < g[node].size();h ++) {
      |                    ~~^~~~~~~~~~~~~~~~
train.cpp:16:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   16 |     for(int h = 0; h < g[node].size(); h++) {
      |                    ~~^~~~~~~~~~~~~~~~
train.cpp: In function 'std::vector<int> first_phase(std::vector<int>, std::vector<int>)':
train.cpp:38:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |     for(int h = 0; h < depend[node].size(); h++) {
      |                    ~~^~~~~~~~~~~~~~~~~~~~~
train.cpp: In function 'int refresh2(int, std::vector<int>&, std::vector<int>&)':
train.cpp:52:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   52 |     for(int h = 0; h < g[node].size(); h++) {
      |                    ~~^~~~~~~~~~~~~~~~
train.cpp:59:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   59 |     for(int h = 0; h < g[node].size(); h++) {
      |                    ~~^~~~~~~~~~~~~~~~
train.cpp: In function 'std::vector<int> second_phase(std::vector<int>&, std::vector<int>&)':
train.cpp:80:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   80 |     for(int h = 0; h < depend[node].size(); h++) {
      |                    ~~^~~~~~~~~~~~~~~~~~~~~
train.cpp:83:19: warning: value computed is not used [-Wunused-value]
   83 |         state[to] == refresh2(to, own, state);
train.cpp: In function 'std::vector<int> who_wins(std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
train.cpp:100:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  100 |   for(int i = 0; i < u.size(); i++) {
      |                  ~~^~~~~~~~~~
#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...