RT
// Author: cnyz
//Looking! The blitz loop this planet to search way.
//Only my RAILGUN can shoot it. 今すぐ
//Modified from official checker.
#include<bits/stdc++.h>
#include"testlib.h"
using namespace std;
const char* check(vector<pair<int, int>> S, int v, vector<pair<int, int>> T) {
int max_begin = T[0].first;
for (int i=1; i<(int)T.size(); ++i) {
if (T[i].second < max_begin) return "wrong chronology";
max_begin = max(max_begin, T[i].first);
}
vector<pair<int, pair<int, int>>> events;
for (int i=0; i<(int)T.size(); ++i) {
events.push_back(make_pair(T[i].first, make_pair(0, i)));
events.push_back(make_pair(T[i].second, make_pair(1, i)));
}
sort(S.begin(), S.end());
sort(T.begin(), T.end());
if (S != T) return "wrong set of intervals";
sort(events.begin(), events.end());
set<int> ac;
for (auto const& e : events) {
if (e.second.first == 0) {
ac.insert(e.second.second);
int span = *ac.rbegin() - *ac.begin();
if (span > v) return "bandwidth greater than declared";
}
else ac.erase(e.second.second);
}
return nullptr;
}
int main(int argc, char** argv) {
registerTestlibCmd(argc,argv);
int all=inf.readInt();
int bad=0, first;
const char* msg;
for (int t=1; t<=all; ++t) {
int n;
n=inf.readInt();
vector<pair<int, int>> S(n);
for (int i=0; i<n; ++i) {
S[i].first=inf.readInt();
S[i].second=inf.readInt();
}
int h=ans.readInt(),o=ouf.readInt();
assert(0 <= o && o < n);
vector<pair<int, int>> T(n);
for (int i=0; i<n; ++i) {
T[i].first=ouf.readInt(),
T[i].second=ouf.readInt();
}
const char* res = check(std::move(S), o, std::move(T));
if (!res) {
if (o>h) res = "bandwidth greater than optimal";
if (o<h) res = "bandwidth less than optimal";
}
if (res) {
if (bad==0) {
first = t;
msg = res;
}
++bad;
}
}
if (bad>0) {
quitf(_wa,"Bad answers:%d/%d (%.2f%%)\nTest #%d: %s\n",
bad, all, 100.0*bad/all, first, msg);
return 0;
}
quitf(_ok,"ORZ\n");
return 0;
}