이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "routers.h"
#define fi first
#define se second
#define all(a) (a).begin(), (a).end()
using namespace std;
using pii = pair<int, int>;
using ti3 = tuple<int, int, int>;
static int l, n, q;
static std::vector<int> p;
static std::vector<int> answer;
static int queries = 0;
const int MAX = 100010;
int arr[MAX], fir[MAX], cnt[MAX], res[MAX];
int lowerBound(int lo, int hi, int tar) { // tar + 1반환
while (lo + 1 < hi) {
int mid = (lo + hi) / 2;
int chk = use_detector(mid);
if (chk < tar) lo = mid;
else hi = mid;
}
return hi;
}
void divide(int lo, int hi) {
int mid = (lo + hi) / 2;
int tar = use_detector(mid);
int lft = lowerBound(lo, hi, tar);
int rgt = lowerBound(lo, hi, tar + 1) - 1;
arr[lft] = tar;
arr[rgt] = tar;
if (lo + 1 < lft) divide(lo, lft - 1);
if (rgt + 1 < hi) divide(rgt, hi);
}
std::vector<int> find_routers(int l, int n, int q) {
for (int i = 0; i < MAX; i++) arr[i] = -1;
divide(-1, l + 1);
for (int i = 1; i < l; i++) arr[i] = max(arr[i], arr[i - 1]);
for (int i = 0; i < l + 1; i++) {
if (arr[i] >= 0) cnt[arr[i]]++;
if (i >= 1 && arr[i] > arr[i - 1]) fir[arr[i]] = i;
}
fir[0] = 0;
res[0] = 0;
for (int i = 1; i < n; i++) {
res[i] = res[i - 1] + (cnt[i - 1] - 1) * 2;
cnt[i] -= cnt[i - 1] - 2;
}
vector<int> v;
for (int i = 0; i < n; i++) v.push_back(res[i]);
return v;
}
컴파일 시 표준 에러 (stderr) 메시지
routers.cpp:15:12: warning: 'queries' defined but not used [-Wunused-variable]
15 | static int queries = 0;
| ^~~~~~~
routers.cpp:12:18: warning: 'q' defined but not used [-Wunused-variable]
12 | static int l, n, q;
| ^
routers.cpp:12:15: warning: 'n' defined but not used [-Wunused-variable]
12 | static int l, n, q;
| ^
routers.cpp:12:12: warning: 'l' defined but not used [-Wunused-variable]
12 | static int l, n, q;
| ^
# | 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... |