제출 #53482

#제출 시각아이디문제언어결과실행 시간메모리
53482jwvg0425장난감 기차 (IOI17_train)C++17
100 / 100
3739 ms1904 KiB
#include "train.h" #include<cstdio> #include<algorithm> #include<vector> #include<queue> using namespace std; int n, m, D[5010], U[5010], InQ[5010], C[5010]; vector<int>E[5010], F[5010]; vector<int> who_wins(vector<int> a, vector<int> r, vector<int> u, vector<int> v) { n = a.size(); m = u.size(); int i, j, k; for (i = 0; i < n; i++) { if (r[i] == 1)D[i] = 1; else D[i] = 0; } queue<int>Q; for (i = 0; i < m; i++) { E[u[i]].push_back(v[i]); F[v[i]].push_back(u[i]); } for (i = 0; i < n; i++) { if (a[i] == 1) { for (auto &t : E[i]) { if (D[i] < D[t] + r[i]) { Q.push(i); InQ[i] = 1; break; } } } if (a[i] == 0) { int ck = 0; for (auto &t : E[i]) { if (D[i] >= D[t] + r[i])C[i]++; } if (C[i] == 0) { Q.push(i); InQ[i] = 1; } } } int cc = 0; while (!Q.empty()) { int x = Q.front(); Q.pop(); InQ[x] = 0; if (a[x] == 1) { int d = -1e9; for (auto &t : E[x]) { d = max(d, D[t] + r[x]); } d = min(d, n); if (D[x] == d) { cc++; continue; } int od = D[x]; D[x] = d; for (auto &t : F[x]) { if (a[t] == 1) { if (D[t] < r[t] + d) { if (!InQ[t]) { InQ[t] = 1; Q.push(t); } } } else { if (D[t] >= r[t] + od && D[t] < r[t] + d) { C[t]--; if (!C[t]) { if (!InQ[t]) { InQ[t] = 1; Q.push(t); } } } } } } else { int d = 1e9; for (auto &t : E[x]) { d = min(d, D[t] + r[x]); } d = min(d, n); if (D[x] == d) { cc++; continue; } C[x] = 0; for (auto &t : E[x]) { if (d >= D[t] + r[x])C[x]++; } int od = D[x]; D[x] = d; for (auto &t : F[x]) { if (a[t] == 1) { if (D[t] < r[t] + d) { if (!InQ[t]) { InQ[t] = 1; Q.push(t); } } } else { int u = D[t]; if (D[t] >= r[t] + od && D[t] < r[t] + d) { C[t]--; if (!C[t]) { if (!InQ[t]) { InQ[t] = 1; Q.push(t); } } } } } D[x] = d; } } vector<int>res(n); for (i = 0; i < n; i++) { if (D[i] >= n)res[i] = 1; else res[i] = 0; } return res; }

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

train.cpp: In function 'std::vector<int> who_wins(std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
train.cpp:35:8: warning: unused variable 'ck' [-Wunused-variable]
    int ck = 0;
        ^~
train.cpp:110:10: warning: unused variable 'u' [-Wunused-variable]
      int u = D[t];
          ^
train.cpp:14:9: warning: unused variable 'j' [-Wunused-variable]
  int i, j, k;
         ^
train.cpp:14:12: warning: unused variable 'k' [-Wunused-variable]
  int i, j, k;
            ^
#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...