Submission #715158

#TimeUsernameProblemLanguageResultExecution timeMemory
715158CyberCowBitaro’s Party (JOI18_bitaro)C++17
0 / 100
2062 ms36428 KiB
#include <iostream> #include <algorithm> #include <vector> #include <queue> #include <set> #include <string> #include <cmath> #include <map> #include <unordered_map> #include <unordered_set> #include <fstream> #include <iomanip> #include <iterator> #include <stack> #include <deque> #define ff first #define ss second using namespace std; using ll = long long; int const N = 200005; vector<int> v[N]; vector<int> vr[N]; vector<pair<int, int>> has[N]; int color[N]; int dp[N]; int ind[N]; int ogt[N]; int sq = 300; void solve() { int n, i, j, m, x, y, a, b, c, q; cin >> n >> m >> q; if (n > 1000 || m > 2000) { return; } for (i = 0; i < m; i++) { for (j = i + 1; j < m; j++) { //cin >> x >> y; x = i + 1; y = j + 1; v[x].push_back(y); vr[y].push_back(x); } } for (i = 1; i <= n; i++) { for (int gg = 0; gg <= sq; gg++) { pair<int, int> ma = { -1, -1 }; for (j = 0; j < vr[i].size(); j++) { while (gg && ind[vr[i][j]] < has[vr[i][j]].size() && ogt[has[vr[i][j]][ind[vr[i][j]]].second] == 1) { ind[vr[i][j]]++; } if (ind[vr[i][j]] < has[vr[i][j]].size()) { ma = max(ma, has[vr[i][j]][ind[vr[i][j]]]); } } for (j = 0; j < vr[i].size(); j++) { ind[vr[i][j]] = 0; } if (ma == make_pair(-1, -1)) { break; } has[i].push_back(ma); has[i].back().first++; ogt[ma.second] = 1; } has[i].push_back({ 0, i }); for ( j = 0; j < has[i].size(); j++) { ogt[has[i][j].second] = 0; } } for (i = 0; i < q; i++) { cin >> x >> y; vector<int> nsh; for (j = 0; j < y; j++) { cin >> c; nsh.push_back(c); color[c] = -1; } if (y >= sq) { for (j = 1; j <= x; j++) { dp[j] = -1; } for (j = 1; j <= x; j++) { if (color[j] == 0) dp[j] = max(dp[j], 0); if (dp[j] != -1) for (int h = 0; h < v[j].size(); h++) { dp[v[j][h]] = max(dp[v[j][h]], dp[j] + 1); } } cout << dp[x] << '\n'; } else { int st = 1; for (j = 0; j < has[x].size(); j++) { if (color[has[x][j].second] == 0) { cout << has[x][j].first << '\n'; st = 0; break; } } if (st) cout << -1 << '\n'; } for (j = 0; j < nsh.size(); j++) { color[nsh[j]] = 0; } } } int main() { ios_base::sync_with_stdio(false); cin.tie(0); int tt = 1; //cin >> tt; while (tt--) { solve(); } return 0; }

Compilation message (stderr)

bitaro.cpp: In function 'void solve()':
bitaro.cpp:54:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   54 |    for (j = 0; j < vr[i].size(); j++)
      |                ~~^~~~~~~~~~~~~~
bitaro.cpp:56:32: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   56 |     while (gg && ind[vr[i][j]] < has[vr[i][j]].size() && ogt[has[vr[i][j]][ind[vr[i][j]]].second] == 1)
      |                  ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
bitaro.cpp:60:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   60 |     if (ind[vr[i][j]] < has[vr[i][j]].size())
      |         ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
bitaro.cpp:65:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   65 |    for (j = 0; j < vr[i].size(); j++)
      |                ~~^~~~~~~~~~~~~~
bitaro.cpp:78:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   78 |   for ( j = 0; j < has[i].size(); j++)
      |                ~~^~~~~~~~~~~~~~~
bitaro.cpp:104:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  104 |      for (int h = 0; h < v[j].size(); h++)
      |                      ~~^~~~~~~~~~~~~
bitaro.cpp:114:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  114 |    for (j = 0; j < has[x].size(); j++)
      |                ~~^~~~~~~~~~~~~~~
bitaro.cpp:126:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  126 |   for (j = 0; j < nsh.size(); j++)
      |               ~~^~~~~~~~~~~~
bitaro.cpp:32:24: warning: unused variable 'a' [-Wunused-variable]
   32 |  int n, i, j, m, x, y, a, b, c, q;
      |                        ^
bitaro.cpp:32:27: warning: unused variable 'b' [-Wunused-variable]
   32 |  int n, i, j, m, x, y, a, b, c, q;
      |                           ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...