This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
// absolutely incredible
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for(int i = a; i <= b; ++i)
#define REP(i, a, b) for(int i = a; i >= b; --i)
#define pb push_back
#define left _________left
#define right _________right
#define NAME ""
const int mod = 1e9 + 7;
bool maximize(int &u, int v){
if(v > v){
u = v;
return true;
}
return false;
}
bool minimize(int &u, int v){
if(v < u){
u = v;
return true;
}
return false;
}
bool maximizell(long long &u, long long v){
if(v > u){
u = v;
return true;
}
return false;
}
bool minimizell(long long &u, long long v){
if(v < u){
u = v;
return true;
}
return false;
}
int fastPow(int a, int n){
if(n == 0) return 1;
int t = fastPow(a, n >> 1);
t = 1ll * t * t % mod;
if(n & 1) t = 1ll * t * a % mod;
return t;
}
void add(int &u, int v){
u += v;
if(u >= mod) u -= mod;
}
void sub(int &u, int v){
u -= v;
if(u < 0) u += mod;
}
const int maxN = 2e5 + 5;
int n, m, q, l[maxN], r[maxN];
namespace subtask12{
bool check(){
return n <= 2000 && m <= 2000;
}
int last[maxN];
const int lim = 4e6 + 1;
int t[lim], cnt;
int res[lim];
void solve(){
FOR(i, 1, m){
FOR(j, l[i], r[i]){
t[++cnt] = j;
}
}
FOR(i, 1, cnt){
if(last[t[i]] == 0)last[t[i]] = i;
else{
res[i - last[t[i]] - 1]++;
last[t[i]] = i;
}
}
REP(i, 399999, 0)res[i] += res[i + 1];
while(q--){
long long s;
cin >> s;
if(s >= 4000000)cout << 0 << " ";
else cout << res[s] << " ";
}
}
}
void solve(){
cin >> n >> m >> q;
FOR(i, 1, m)cin >> l[i] >> r[i];
if(subtask12 :: check()) return subtask12 :: solve();
}
int main(){
if(fopen(NAME"inp", "r")){
freopen(NAME".inp", "r", stdin);
freopen(NAME".out", "w", stdout);
}
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int t = 1;
// cin >> t;
while(t--){
solve();
}
return 0;
}
Compilation message (stderr)
Main.cpp: In function 'bool maximize(int&, int)':
Main.cpp:12:10: warning: self-comparison always evaluates to false [-Wtautological-compare]
12 | if(v > v){
| ~ ^ ~
Main.cpp: In function 'int main()':
Main.cpp:93:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
93 | freopen(NAME".inp", "r", stdin);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:94:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
94 | freopen(NAME".out", "w", stdout);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
# | 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... |