제출 #883565

#제출 시각아이디문제언어결과실행 시간메모리
883565kongumFinding Routers (IOI20_routers)C++17
48.79 / 100
2 ms1112 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...