이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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;
}
컴파일 시 표준 에러 (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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |