# |
제출 시각 |
아이디 |
문제 |
언어 |
결과 |
실행 시간 |
메모리 |
1083221 |
2024-09-02T18:32:17 Z |
modwwe |
벽 (IOI14_wall) |
C++17 |
|
395 ms |
104688 KB |
#pragma GCC optimize("Ofast,unroll-loops")
#include "wall.h"
#include<bits/stdc++.h>
//#define int long long
//#define ll long long
#define down cout<<'\n';
#define debug cout<<" cucuucucuuu",down
#define NHP ios_base::sync_with_stdio(0);cout.tie(0);cin.tie(0);
#define modwwe int t;cin>>t; while(t--)
#define bit(i,j) (i>>j&1)
#define sobit(a) __builtin_popcountll(a)
#define task "test"
#define fin(x) freopen(x".inp","r",stdin)
#define fou(x) freopen(x".ans","w",stdout)
#define pb push_back
#define checktime cerr << (double)clock() / CLOCKS_PER_SEC * 1000 << " ms";
using namespace std;
#define getchar_unlocked getchar
inline int scan()
{
char c = getchar_unlocked();
int x = 0;
while(c<'0'||c>'9')
{
c=getchar_unlocked();
}
while(c>='0'&&c<='9')
{
x=(x<<1)+(x<<3)+c-'0';
c=getchar_unlocked();
}
return x;
}
void phongbeo();
const int inf=1e9;
const int mod2=998244353;
const int mod1=998244353;
struct icd
{
long double a;
int b;
};
struct ib
{
int a;
int b;
};
struct ic
{
int a,b,c;
};
struct id
{
int a,b,c,d;
};
struct ie
{
int a,b,c,d,e;
};
int n,m,s1,s2,s4,s3,sf,k,s5,s6,mx,s7,s8,s9,mx2,res,dem2=0,dem=0,s33,dem3,dem4,l,r,mid,l2,r2;
int i,s10,s12;
int kk;
int el=29;
struct IT
{
ib t[8000001];
bool t2[8000001];
void ff(int x)
{
if(!t2[x]) return;
for(int i=x*2; i<=x*2+1; i++)
if(t2[i]==0)
{
t[i]=t[x];
t2[i]=t2[x];
}
else
{
t[i].b=min(t[i].b,t[x].b);
t[i].a=max(t[i].a,t[x].a);
if(t[x].b<t[i].a)
t[i].a=t[i].b;
if(t[x].a>t[i].b)
t[i].b=t[i].a;
}
t[x].a=0;
t[x].b=1e9;
t2[x]=0;
}
void upd(int node,int l,int r,int l1,int r1,int x,bool d)
{
if(l>r1||r<l1) return;
if(l>=l1&&r<=r1)
{
if(!d)
{
t[node].b=min(t[node].b,x);
t[node].a=min(t[node].a,x);
}
else
{
t[node].a=max(t[node].a,x);
t[node].b=max(t[node].b,x);
}
t2[node]=1;
return;
}
ff(node);
int mid=l+r>>1;
upd(node<<1,l,mid,l1,r1,x,d);
upd(node<<1|1,mid+1,r,l1,r1,x,d);
}
void setup(int node,int l,int r,int c[])
{
if(l==r)
{
c[l-1]=t[node].a;
return;
}
int mid=l+r>>1;
ff(node);
setup(node<<1,l,mid,c);
setup(node<<1|1,mid+1,r,c);
}
} st;
void buildWall(int n, int k, int op[], int left[], int right[], int height[], int finalHeight[])
{
for(int i=1; i<=n*4; i++)
st.t[i].b=1e9;
for(int i=0; i<k; i++)
{
if(op[i]==1)
{
l=left[i];
r=right[i];
s2=height[i];
st.upd(1,1,n,l+1,r+1,s2,1);
}
else
{
l=left[i];
r=right[i];
s2=height[i];
st.upd(1,1,n,l+1,r+1,s2,0);
}
}
st.setup(1,1,n,finalHeight);
}
Compilation message
wall.cpp: In member function 'void IT::upd(int, int, int, int, int, int, bool)':
wall.cpp:114:18: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
114 | int mid=l+r>>1;
| ~^~
wall.cpp: In member function 'void IT::setup(int, int, int, int*)':
wall.cpp:125:18: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
125 | int mid=l+r>>1;
| ~^~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2396 KB |
Output is correct |
2 |
Correct |
1 ms |
2396 KB |
Output is correct |
3 |
Correct |
2 ms |
348 KB |
Output is correct |
4 |
Correct |
4 ms |
2908 KB |
Output is correct |
5 |
Correct |
3 ms |
2904 KB |
Output is correct |
6 |
Correct |
3 ms |
2892 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2396 KB |
Output is correct |
2 |
Correct |
91 ms |
16136 KB |
Output is correct |
3 |
Correct |
119 ms |
9812 KB |
Output is correct |
4 |
Correct |
343 ms |
22868 KB |
Output is correct |
5 |
Correct |
165 ms |
23892 KB |
Output is correct |
6 |
Correct |
141 ms |
22360 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2396 KB |
Output is correct |
2 |
Correct |
1 ms |
2628 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
4 ms |
2892 KB |
Output is correct |
5 |
Correct |
3 ms |
2908 KB |
Output is correct |
6 |
Correct |
3 ms |
2908 KB |
Output is correct |
7 |
Correct |
0 ms |
2396 KB |
Output is correct |
8 |
Correct |
91 ms |
16124 KB |
Output is correct |
9 |
Correct |
116 ms |
9812 KB |
Output is correct |
10 |
Correct |
348 ms |
22864 KB |
Output is correct |
11 |
Correct |
157 ms |
23888 KB |
Output is correct |
12 |
Correct |
146 ms |
22428 KB |
Output is correct |
13 |
Correct |
1 ms |
2392 KB |
Output is correct |
14 |
Correct |
85 ms |
16100 KB |
Output is correct |
15 |
Correct |
22 ms |
3932 KB |
Output is correct |
16 |
Correct |
395 ms |
23124 KB |
Output is correct |
17 |
Correct |
147 ms |
22608 KB |
Output is correct |
18 |
Correct |
147 ms |
22612 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2392 KB |
Output is correct |
2 |
Correct |
1 ms |
2396 KB |
Output is correct |
3 |
Correct |
1 ms |
344 KB |
Output is correct |
4 |
Correct |
5 ms |
2896 KB |
Output is correct |
5 |
Correct |
3 ms |
2908 KB |
Output is correct |
6 |
Correct |
3 ms |
2908 KB |
Output is correct |
7 |
Correct |
0 ms |
2396 KB |
Output is correct |
8 |
Correct |
82 ms |
16136 KB |
Output is correct |
9 |
Correct |
128 ms |
9808 KB |
Output is correct |
10 |
Correct |
339 ms |
23124 KB |
Output is correct |
11 |
Correct |
149 ms |
23976 KB |
Output is correct |
12 |
Correct |
134 ms |
22296 KB |
Output is correct |
13 |
Correct |
1 ms |
2392 KB |
Output is correct |
14 |
Correct |
83 ms |
15952 KB |
Output is correct |
15 |
Correct |
21 ms |
3780 KB |
Output is correct |
16 |
Correct |
394 ms |
23068 KB |
Output is correct |
17 |
Correct |
157 ms |
22608 KB |
Output is correct |
18 |
Correct |
148 ms |
22608 KB |
Output is correct |
19 |
Correct |
334 ms |
104688 KB |
Output is correct |
20 |
Correct |
351 ms |
102004 KB |
Output is correct |
21 |
Correct |
343 ms |
103508 KB |
Output is correct |
22 |
Correct |
341 ms |
100948 KB |
Output is correct |
23 |
Correct |
339 ms |
100948 KB |
Output is correct |
24 |
Correct |
353 ms |
100844 KB |
Output is correct |
25 |
Correct |
335 ms |
101968 KB |
Output is correct |
26 |
Correct |
352 ms |
103376 KB |
Output is correct |
27 |
Correct |
351 ms |
103504 KB |
Output is correct |
28 |
Correct |
335 ms |
100800 KB |
Output is correct |
29 |
Correct |
332 ms |
101968 KB |
Output is correct |
30 |
Correct |
344 ms |
102048 KB |
Output is correct |