# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
900551 | qin | Cell Automaton (JOI23_cell) | C++17 | 346 ms | 48296 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define fi first
#define se second
#define ssize(x) int(x.size())
#define pn printf("\n");
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
int inf = 2e09; ll infll = 2e18; int mod = 119<<23|1;
struct st{
int t, type; ll c;
bool operator<(const st &x) const{ return t == x.t ? type < x.type : t < x.t; }
};
void answer(){
int n, q; scanf("%d%d", &n, &q);
vector<int> t(n);
for(int i = 0; i < n; ++i){
int x, y; scanf("%d%d", &x, &y);
t[i] = x;
}
sort(t.begin(), t.end());
vector<st> ev;
vector<int> qr(q);
for(int i = 0; i < q; ++i){
int T; scanf("%d", &T); qr[i] = T;
ev.push_back({T, 2, 0});
}
for(int i = 0; i < n-1; ++i){
ev.push_back({t[i+1]-t[i], 0, t[i+1]-t[i]+1});
ev.push_back({t[i+1]-t[i]+1, 1, t[i+1]-t[i]+3});
}
sort(ev.begin(), ev.end());
unordered_map<int, ll> result;
ll offset = 0, cnt = n;
for(st u : ev){
//~ printf("%d %d %lld\n", u.t, u.type, u.c);
if(u.type == 2) result[u.t] = (ll(u.t)*4*cnt)-offset;
else offset += u.c;
if(u.type == 1) --cnt, offset -= 4ll*u.t;
} result[0] = n;
for(int i = 0; i < q; ++i) printf("%lld\n", result[qr[i]]);
}
signed main(){
int T = 1;
for(++T; --T; ) answer();
return 0;
}
Compilation message (stderr)
# | 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... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |