제출 #287600

#제출 시각아이디문제언어결과실행 시간메모리
287600evpipis장난감 기차 (IOI17_train)C++11
100 / 100
1008 ms1552 KiB
#include <bits/stdc++.h> #include "train.h" using namespace std; #define pb push_back typedef vector<int> vi; const int len = 5005; int vis[len], block[len], bel[len], deg[len], n; vector<int> adj[len]; vi operator-(vi a, vi b){ sort(a.begin(), a.end()); sort(b.begin(), b.end()); vi res; for (int i = 0, j = 0; i < a.size(); i++){ while (j < b.size() && b[j] < a[i]) j++; if (j == b.size() || b[j] > a[i]) res.pb(a[i]); } return res; } vi func(int sub, vi base){ for (int u = 0; u < n; u++) vis[u] = deg[u] = 0; for (int u = 0; u < n; u++){ if (block[u]) continue; for (auto v: adj[u]) if (!block[v]) deg[v]++; } queue<int> myq; for (auto u: base) vis[u] = 1, myq.push(u); while (!myq.empty()){ int u = myq.front(); myq.pop(); for (auto v: adj[u]){ if (block[v] || vis[v]) continue; if (bel[v] == sub) vis[v] = 1, myq.push(v); else{ deg[v]--; if (!deg[v]) vis[v] = 1, myq.push(v); } } } vi res; for (int i = 0; i < n; i++) if (!block[i] && vis[i]) res.pb(i); return res; } vi who_wins(vi B, vi spec, vi U, vi V) { n = B.size(); for (int i = 0; i < U.size(); i++){ int a = U[i], b = V[i]; adj[b].pb(a); } vi graph; for (int i = 0; i < n; i++) graph.pb(i), block[i] = 0, bel[i] = B[i]; while (!graph.empty()){ vi reach, rest; for (auto u: graph) if (spec[u]) reach.pb(u); reach = func(1, reach); rest = func(0, graph-reach); if (rest.size() == 0) break; for (auto u: rest) block[u] = 1; graph = graph-rest; } vi res(n, 0); for (auto u: graph) res[u] = 1; return res; }

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

train.cpp: In function 'vi operator-(vi, vi)':
train.cpp:18:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   18 |     for (int i = 0, j = 0; i < a.size(); i++){
      |                            ~~^~~~~~~~~~
train.cpp:19:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   19 |         while (j < b.size() && b[j] < a[i])
      |                ~~^~~~~~~~~~
train.cpp:22:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |         if (j == b.size() || b[j] > a[i])
      |             ~~^~~~~~~~~~~
train.cpp: In function 'vi who_wins(vi, vi, vi, vi)':
train.cpp:72:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   72 |     for (int i = 0; i < U.size(); i++){
      |                     ~~^~~~~~~~~~
train.cpp:100:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
  100 |     for (auto u: graph)
      |     ^~~
train.cpp:102:2: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
  102 |  return res;
      |  ^~~~~~
#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...