이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <iostream>
#include <algorithm>
#include <cstring>
#include <sstream>
#include <map>
#include <queue>
#include <set>
#include <vector>
#include <stack>
#include <cstdio>
#include <cmath>
#include <bitset>
#define mk make_pair
#define pb push_back
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> pos;
const ll MOD = 1000000007, N =60010, dx[4] = { -1,1,0,0 }, dy[4] = { 0,0,-1,1 }, MIN = -7230040172838, MAX = 7230040172838;
const int S = 60;
ll mn(ll a, ll b) {
if (a == -1)return b;
if (b == -1)return a;
return min(a, b);
}
static ll gcd(ll v1, ll v2) {
if (v1 == 0)return v2; if (v2 == 0)return v1; if (v2 > v1)return gcd(v2%v1, v1); return gcd(v1%v2, v2);
}
ll pw(ll v1, ll v2) {
ll v3 = 1;
while (v2 > 0) {
if (v2 % 2)v3 = (v3*v1) % MOD;
v1 = (v1*v1) % MOD;
v2 /= 2;
}
return v3;
}
int n, q, as[N], k, sid = 1,sid2=1;
pair<int, pos> si[N],sd[N];
pair<pos, int> qr[N];
multiset<int> l1[410], l2[410];
int main() {
cin >> n >> k >> q;
for (int i = 1; i <= n; i++) {
int v1, v2, v3, v4;
cin >> v1 >> v2 >> v3 >> v4;
si[i] = mk(v3, mk(v1, v2));
sd[i] = mk(v4, mk(v1, v2));
}
sort(si + 1, si + n + 1);
sort(sd + 1, sd + n + 1);
for (int i = 0; i < q; i++) { cin >> qr[i].first.second >> qr[i].first.first; qr[i].second = i; }
sort(qr, qr + q);
for (int i = 0; i < q; i++) {
ll xi = qr[i].first.second,tv=qr[i].first.first;
ll cv = -1;
for (; sid <= n && si[sid].first <= tv; sid++) {
int v1 = si[sid].second.first, v2 = si[sid].second.second;
l1[v2].insert(v1);
l2[v2].insert(-v1);
}
for (; sid2 <= n && sd[sid2].first < tv; sid2++) {
int v1 = sd[sid2].second.first, v2 = sd[sid2].second.second;
l1[v2].erase(l1[v2].find(v1));
l2[v2].erase(l2[v2].find(-v1));
}
for (int j = 1; j <= k; j++) {
if (l1[j].empty()) { cv = -1; break; }
auto v1 = l1[j].lower_bound(xi), v2 = l2[j].lower_bound(-xi);
ll cv2 = MAX;
if (v1 != l1[j].end()) { cv2 = min(cv2, abs(*v1 - xi)); }
if (v2 != l2[j].end()) { cv2 = min(cv2, abs(-*v2 - xi)); }
cv = max(cv, cv2);
}
as[qr[i].second] = cv;
}
for (int i = 0; i < q; i++)cout << as[i] << endl;
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
new_home.cpp: In function 'll gcd(ll, ll)':
new_home.cpp:27:2: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
if (v1 == 0)return v2; if (v2 == 0)return v1; if (v2 > v1)return gcd(v2%v1, v1); return gcd(v1%v2, v2);
^~
new_home.cpp:27:25: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
if (v1 == 0)return v2; if (v2 == 0)return v1; if (v2 > v1)return gcd(v2%v1, v1); return gcd(v1%v2, v2);
^~
# | 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... |