Submission #998984

#TimeUsernameProblemLanguageResultExecution timeMemory
998984phoebeSeptember (APIO24_september)C++17
100 / 100
134 ms8868 KiB
#include <bits/stdc++.h> #include "september.h" using namespace std; // #define int long long #define ll long long #define FOR(i, n) for (int i = 0; i < n; i++) #define NYOOM ios::sync_with_stdio(0); cin.tie(0); #define pii pair<int, int> #define F first #define S second #define PB push_back #define ALL(x) x.begin(), x.end() #define endl '\n' const int INF = 1e9 + 7; const long long LLINF = 1ll<<60; int solve(int n, int m, vector<int> f, vector<vector<int>> s){ f[0] = 0; vector<pii> ranges; int mn[n], mx[n], idx[n]; fill(mn, mn + n, n); fill(mx, mx + n, -1); FOR(i, m){ fill(idx, idx + n, -1); FOR(j, n - 1){ mn[s[i][j]] = min(mn[s[i][j]], j); mx[s[i][j]] = max(mx[s[i][j]], j); if (idx[f[s[i][j]]] != -1) ranges.PB({idx[f[s[i][j]]], j}); idx[s[i][j]] = j; } } FOR(i, n) ranges.PB({mn[i], mx[i]}); sort(ALL(ranges)); int re = 0, l = 0, r = 0, i = 0; while (l < n - 1){ while (i < ranges.size() && ranges[i].F <= r){ r = max(r, ranges[i].S); i++; } re++; l = r + 1; r++; } return re; }

Compilation message (stderr)

september.cpp: In function 'int solve(int, int, std::vector<int>, std::vector<std::vector<int> >)':
september.cpp:36: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]
   36 |         while (i < ranges.size() && ranges[i].F <= r){
      |                ~~^~~~~~~~~~~~~~~
#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...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...