QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#46027 | #2164. Landscape Generator | dmga44# | WA | 214ms | 28184kb | C++20 | 4.6kb | 2022-08-24 21:19:33 | 2022-08-24 21:19:36 |
Judging History
answer
// #pragma GCC optimize("Ofast,no-stack-protector,unroll-loops", "omit-frame-pointer", "inline")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.1,sse4.2,popcnt,abm,mmx,avx,avx2,fma,tune=native")
// #pragma GCC option("arch=native", "no-zero-upper") // Enable AVX
/// UH Top
#include <bits/stdc++.h>
#define db(x) cerr << #x << ':' << (x) << '\n';
#define all(v) (v).begin(), (v).end()
#define allr(v) (v).rbegin(), (v).rend()
// #define int ll
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
// typedef __int128_t int128;
typedef pair<ll, ll> pii;
typedef pair<ld, ll> pdi;
typedef pair<ld, ld> pdd;
typedef pair<ld, pdd> pdp;
typedef pair<string, ll> psi;
typedef pair<ll, string> pls;
typedef pair<string, string> pss;
typedef pair<ll, pii> pip;
typedef pair<pii, pii> ppp;
typedef complex<ld> point;
typedef vector<point> polygon;
typedef vector<ll> vi;
typedef pair<point, int> ppi;
#define prec(n) \
cout.precision(n); \
cout << fixed
const ll mod = (1e9 + 7);
const ld eps = (1e-9);
const ll oo = (ll)(1e18 + 5);
#define pi acos(-1)
#define MAXN (ll)(1e6 + 5)
pii operator+(pii a,pii b)
{
return pii(a.first+b.first,a.second+b.second);
}
pii operator-(pii a,pii b)
{
return pii(a.first-b.first,a.second-b.second);
}
template <typename T>
struct ST{
vector< T > st,lazy;
int sz;
T neutroL;
ST (int n,T neutrol) : sz(n),st(4*n),lazy(4*n),neutroL(neutrol) {}
T merge(T v1,T v2)
{
return v1+v2;
}
void up(int p,int l,int r,T v)
{
st[p]=st[p]+v;
lazy[p]=lazy[p]+v;
}
void push(int p,int l,int r)
{
if(l==r)
{
lazy[p]=neutroL;
return ;
}
if(lazy[p]==neutroL)
return ;
///(basic) up to code
T v=lazy[p];
up((p<<1),l,(l+r)>>1,v);
up((p<<1)+1,((l+r)>>1)+1,r,v);
lazy[p]=neutroL;
}
void build(vector<T> &arr) { build(1,0,sz-1,arr); }
void build(int p,int l,int r,vector<T> &arr)
{
if(l==r)
{
st[p]=arr[l];
lazy[p]=neutroL;
return ;
}
int mid=(l+r)>>1;
build(p<<1,l,mid,arr);
build((p<<1)+1,mid+1,r,arr);
st[p]=merge(st[p<<1],st[(p<<1)+1]);
lazy[p]=neutroL;
}
void build(T *arr) { build(1,0,sz-1,arr); }
void build(int p,int l,int r,T *arr)
{
if(l==r)
{
st[p]=arr[l];
lazy[p]=neutroL;
return ;
}
int mid=(l+r)>>1;
build(p<<1,l,mid,arr);
build((p<<1)+1,mid+1,r,arr);
st[p]=merge(st[p<<1],st[(p<<1)+1]);
lazy[p]=neutroL;
}
void update(int L,int R,T v) { update(1,0,sz-1,L,R,v); }
void update(int p,int l,int r,int L,int R,T v)
{
push(p,l,r);
if(L<=l && r<=R)
{
up(p,l,r,v);
return ;
}
int mid=(l+r)>>1;
if(L<=mid)
update(p<<1,l,mid,L,R,v);
if(R>mid)
update((p<<1)+1,mid+1,r,L,R,v);
st[p]=merge(st[p<<1],st[(p<<1)+1]);
}
T query(int L,int R) { return query(1,0,sz-1,L,R); }
T query(int p,int l,int r,int L,int R)
{
push(p,l,r);
if(L<=l && r<=R)
return st[p];
int mid=(l+r)>>1;
if(R<=mid)
return query(p<<1,l,mid,L,R);
if(L>mid)
return query((p<<1)+1,mid+1,r,L,R);
return merge(query(p<<1,l,mid,L,R),query((p<<1)+1,mid+1,r,L,R));
}
};
int32_t main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
int n,q;
cin >> n >> q;
ST<pii> st(n,pii(0,0));
for(int i=0;i<q;i++)
{
char c;
int x1,x2;
cin >> c >> x1 >> x2;
x1--,x2--;
if(c=='R')
{
st.update(x1,x2,pii(1,0));
}
if(c=='D')
{
st.update(x1,x2,pii(-1,0));
}
if(c=='H')
{
int mid=(x1+x2)>>1;
int rmid=mid+1;
st.update(x1,mid,pii(-(x1-1),1));
st.update(rmid,x2,pii(x2+1,-1));
}
if(c=='V')
{
int mid=(x1+x2)>>1;
int rmid=mid+1;
st.update(x1,mid,pii((x1-1),-1));
st.update(rmid,x2,pii(-(x2+1),1));
}
}
for(int i=0;i<n;i++)
{
pii x=st.query(i,i);
cout << x.first+x.second*i << '\n';
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 4ms
memory: 3548kb
input:
71 1487 H 20 68 D 22 52 H 39 55 V 8 58 V 56 61 V 1 30 V 3 11 V 40 49 H 4 24 H 27 68 H 28 36 R 7 30 V 4 42 V 9 24 D 7 15 R 2 31 V 29 51 R 9 11 V 69 69 R 65 70 H 2 56 V 21 22 D 23 35 H 23 47 D 59 60 D 16 50 V 3 26 V 64 70 H 28 31 R 24 25 H 4 70 D 1 42 D 39 39 D 11 33 V 16 68 H 53 71 V 2 71 H 26 47 H 5...
output:
-2 4 12 30 48 60 68 85 99 89 79 64 49 33 9 -12 -27 -20 -39 -54 -71 -85 -89 -85 -88 -97 -102 -100 -84 -64 -48 -25 -19 -20 -19 -12 6 23 36 48 61 77 96 105 106 106 99 79 65 59 56 49 45 35 28 22 16 19 14 8 6 9 13 10 1 -8 -12 -3 4 -5 2
result:
ok 71 lines
Test #2:
score: 0
Accepted
time: 214ms
memory: 23748kb
input:
165231 181869 V 97560 131310 R 4568 154037 R 84344 137004 H 46615 141921 D 93109 94547 R 32071 94168 R 89189 111905 D 1300 93577 V 105118 165223 D 110827 147567 V 3993 32756 D 143493 154640 V 42532 83628 R 48218 132610 R 9781 68504 R 70797 110884 H 131654 143886 D 92398 131461 H 82803 154957 H 22377...
output:
-1 -2 -2 1 1 6 11 15 19 23 28 34 43 48 53 60 69 78 86 93 101 106 115 122 130 137 144 155 164 175 186 199 213 224 233 243 252 261 273 285 299 310 321 333 345 356 365 378 393 406 419 432 443 454 468 483 499 513 527 539 551 564 581 597 617 637 655 672 688 705 720 737 753 768 783 799 817 832 847 862 878...
result:
ok 165231 lines
Test #3:
score: 0
Accepted
time: 91ms
memory: 28132kb
input:
200000 200000 D 1 200000 D 2 200000 D 3 200000 D 4 200000 D 5 200000 D 6 200000 D 7 200000 D 8 200000 D 9 200000 D 10 200000 D 11 200000 D 12 200000 D 13 200000 D 14 200000 D 15 200000 D 16 200000 D 17 200000 D 18 200000 D 19 200000 D 20 200000 D 21 200000 D 22 200000 D 23 200000 D 24 200000 D 25 20...
output:
-1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -15 -16 -17 -18 -19 -20 -21 -22 -23 -24 -25 -26 -27 -28 -29 -30 -31 -32 -33 -34 -35 -36 -37 -38 -39 -40 -41 -42 -43 -44 -45 -46 -47 -48 -49 -50 -51 -52 -53 -54 -55 -56 -57 -58 -59 -60 -61 -62 -63 -64 -65 -66 -67 -68 -69 -70 -71 -72 -73 -74 -75 -76 -77 -...
result:
ok 200000 lines
Test #4:
score: -100
Wrong Answer
time: 150ms
memory: 28184kb
input:
200000 200000 H 1 200000 H 2 200000 H 3 200000 H 4 200000 H 5 200000 H 6 200000 H 7 200000 H 8 200000 H 9 200000 H 10 200000 H 11 200000 H 12 200000 H 13 200000 H 14 200000 H 15 200000 H 16 200000 H 17 200000 H 18 200000 H 19 200000 H 20 200000 H 21 200000 H 22 200000 H 23 200000 H 24 200000 H 25 20...
output:
1 3 6 10 15 21 28 36 45 55 66 78 91 105 120 136 153 171 190 210 231 253 276 300 325 351 378 406 435 465 496 528 561 595 630 666 703 741 780 820 861 903 946 990 1035 1081 1128 1176 1225 1275 1326 1378 1431 1485 1540 1596 1653 1711 1770 1830 1891 1953 2016 2080 2145 2211 2278 2346 2415 2485 2556 2628 ...
result:
wrong answer 200000th lines differ - expected: '200000', found: '0'