# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1100049 |
2024-10-12T15:14:14 Z |
modwwe |
Sushi (JOI16_sushi) |
C++17 |
|
4900 ms |
80036 KB |
#pragma GCC optimize("Ofast,unroll-loops")
//#pragma GCC optimize("conserve-stack")
#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".out","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 = 1e18;
const int mod2 = 1e9 + 7;
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, center;
int i, s10, s12,k1,k2,k3,s11,t,lim,w;
int kk;
int el = 19;
main()
{
if(fopen(task".inp","r"))
{
fin(task);
fou(task);
}
NHP
/// cin>>s1;
///modwwe
phongbeo();
// checktime
}
vector<int> v[670];
struct chiacan
{
vector<int> a;
int sz=0;
priority_queue<int,vector<int>,greater<int>>p;
priority_queue<int,vector<int>>p2;
void init(vector<int> v)
{
a.resize(v.size()+1);
sz=v.size();
for(int i=1; i<=v.size(); i++)
a[i]=v[i-1],p2.push(a[i]);
}
int upd(int x)
{
p.push({x});
if(p2.top()>x)
{
int ff=p2.top();
p2.pop();
p2.push(x);
x=ff;
}
return x;
}
int reset(int l,int r,int y)
{
for(int i=1; i<=sz; i++)
{
if(!p.empty()&&a[i]>p.top())
{
int ff=a[i];
a[i]=p.top();
p.pop();
p.push(ff);
}
}
while(!p.empty())
p.pop();
while(!p2.empty())
p2.pop();
for(int i=l; i<=r; i++)
{
if(a[i]>y)
{
swap(a[i],y);
}
}
for(int i=1; i<=sz; i++)
p2.push({a[i]});
return y;
}
} bucket[670];
int S=634 ;
int upd(int l,int r,int x)
{
if(l==0) l2=0;
else l2=(l-1)/S+1;
s10=-1;
if(l%S!=0)
{
x=bucket[l/S].reset(l%S+1,min(l-l%S+S-1,r)%S+1,x);
s10=min(l-l%S+S-1,r);
}
r2=(r+1)/S-1;
for(int j=l2; j<=r2; j++)
x=bucket[j].upd(x);
if(s10!=r&&(r+1)%S!=0)
{
x=bucket[r/S].reset(1,r%S+1,x);
}
return x;
}
void phongbeo()
{
cin>>n>>m;
v[0].pb(0);
for(int i=1; i<=n; i++)
{
cin>>l;
v[i/S].pb(l);
}
for(int i=0; i<=n/S; i++)
bucket[i].init(v[i]);
for(int i=1; i<=m; i++)
{
cin>>l>>r>>s2;
if(l<=r)
cout<<upd(l,r,s2);
else
{
s2=upd(l,n,s2);
cout<<upd(0,r,s2);
}
down
}
}
Compilation message
sushi.cpp:37:17: warning: overflow in conversion from 'double' to 'int' changes value from '1.0e+18' to '2147483647' [-Woverflow]
37 | const int inf = 1e18;
| ^~~~
sushi.cpp:69:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
69 | main()
| ^~~~
sushi.cpp: In member function 'void chiacan::init(std::vector<int>)':
sushi.cpp:93:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
93 | for(int i=1; i<=v.size(); i++)
| ~^~~~~~~~~~
sushi.cpp: In function 'int main()':
sushi.cpp:13:23: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
13 | #define fin(x) freopen(x".inp","r",stdin)
| ~~~~~~~^~~~~~~~~~~~~~~~~~~
sushi.cpp:73:9: note: in expansion of macro 'fin'
73 | fin(task);
| ^~~
sushi.cpp:14:23: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
14 | #define fou(x) freopen(x".out","w",stdout)
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~
sushi.cpp:74:9: note: in expansion of macro 'fou'
74 | fou(task);
| ^~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
138 ms |
344 KB |
Output is correct |
2 |
Correct |
115 ms |
348 KB |
Output is correct |
3 |
Correct |
120 ms |
556 KB |
Output is correct |
4 |
Correct |
116 ms |
344 KB |
Output is correct |
5 |
Correct |
116 ms |
344 KB |
Output is correct |
6 |
Correct |
120 ms |
344 KB |
Output is correct |
7 |
Correct |
40 ms |
348 KB |
Output is correct |
8 |
Correct |
33 ms |
344 KB |
Output is correct |
9 |
Correct |
116 ms |
572 KB |
Output is correct |
10 |
Correct |
115 ms |
344 KB |
Output is correct |
11 |
Correct |
111 ms |
564 KB |
Output is correct |
12 |
Correct |
110 ms |
572 KB |
Output is correct |
13 |
Correct |
126 ms |
348 KB |
Output is correct |
14 |
Correct |
127 ms |
348 KB |
Output is correct |
15 |
Correct |
131 ms |
344 KB |
Output is correct |
16 |
Correct |
51 ms |
344 KB |
Output is correct |
17 |
Correct |
0 ms |
344 KB |
Output is correct |
18 |
Correct |
1 ms |
344 KB |
Output is correct |
19 |
Correct |
0 ms |
348 KB |
Output is correct |
20 |
Correct |
0 ms |
348 KB |
Output is correct |
21 |
Correct |
0 ms |
344 KB |
Output is correct |
22 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2367 ms |
79956 KB |
Output is correct |
2 |
Correct |
2494 ms |
79972 KB |
Output is correct |
3 |
Correct |
682 ms |
79700 KB |
Output is correct |
4 |
Correct |
2121 ms |
79872 KB |
Output is correct |
5 |
Correct |
1989 ms |
79956 KB |
Output is correct |
6 |
Correct |
3086 ms |
79844 KB |
Output is correct |
7 |
Correct |
2952 ms |
80036 KB |
Output is correct |
8 |
Correct |
2748 ms |
79948 KB |
Output is correct |
9 |
Correct |
716 ms |
79772 KB |
Output is correct |
10 |
Correct |
2186 ms |
79896 KB |
Output is correct |
11 |
Correct |
618 ms |
79696 KB |
Output is correct |
12 |
Correct |
2124 ms |
79744 KB |
Output is correct |
13 |
Correct |
2114 ms |
79952 KB |
Output is correct |
14 |
Correct |
2408 ms |
79676 KB |
Output is correct |
15 |
Correct |
704 ms |
79712 KB |
Output is correct |
16 |
Correct |
2407 ms |
79804 KB |
Output is correct |
17 |
Correct |
2112 ms |
79864 KB |
Output is correct |
18 |
Correct |
2708 ms |
79956 KB |
Output is correct |
19 |
Correct |
2735 ms |
79836 KB |
Output is correct |
20 |
Correct |
2739 ms |
79948 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
138 ms |
344 KB |
Output is correct |
2 |
Correct |
115 ms |
348 KB |
Output is correct |
3 |
Correct |
120 ms |
556 KB |
Output is correct |
4 |
Correct |
116 ms |
344 KB |
Output is correct |
5 |
Correct |
116 ms |
344 KB |
Output is correct |
6 |
Correct |
120 ms |
344 KB |
Output is correct |
7 |
Correct |
40 ms |
348 KB |
Output is correct |
8 |
Correct |
33 ms |
344 KB |
Output is correct |
9 |
Correct |
116 ms |
572 KB |
Output is correct |
10 |
Correct |
115 ms |
344 KB |
Output is correct |
11 |
Correct |
111 ms |
564 KB |
Output is correct |
12 |
Correct |
110 ms |
572 KB |
Output is correct |
13 |
Correct |
126 ms |
348 KB |
Output is correct |
14 |
Correct |
127 ms |
348 KB |
Output is correct |
15 |
Correct |
131 ms |
344 KB |
Output is correct |
16 |
Correct |
51 ms |
344 KB |
Output is correct |
17 |
Correct |
0 ms |
344 KB |
Output is correct |
18 |
Correct |
1 ms |
344 KB |
Output is correct |
19 |
Correct |
0 ms |
348 KB |
Output is correct |
20 |
Correct |
0 ms |
348 KB |
Output is correct |
21 |
Correct |
0 ms |
344 KB |
Output is correct |
22 |
Correct |
0 ms |
348 KB |
Output is correct |
23 |
Correct |
2367 ms |
79956 KB |
Output is correct |
24 |
Correct |
2494 ms |
79972 KB |
Output is correct |
25 |
Correct |
682 ms |
79700 KB |
Output is correct |
26 |
Correct |
2121 ms |
79872 KB |
Output is correct |
27 |
Correct |
1989 ms |
79956 KB |
Output is correct |
28 |
Correct |
3086 ms |
79844 KB |
Output is correct |
29 |
Correct |
2952 ms |
80036 KB |
Output is correct |
30 |
Correct |
2748 ms |
79948 KB |
Output is correct |
31 |
Correct |
716 ms |
79772 KB |
Output is correct |
32 |
Correct |
2186 ms |
79896 KB |
Output is correct |
33 |
Correct |
618 ms |
79696 KB |
Output is correct |
34 |
Correct |
2124 ms |
79744 KB |
Output is correct |
35 |
Correct |
2114 ms |
79952 KB |
Output is correct |
36 |
Correct |
2408 ms |
79676 KB |
Output is correct |
37 |
Correct |
704 ms |
79712 KB |
Output is correct |
38 |
Correct |
2407 ms |
79804 KB |
Output is correct |
39 |
Correct |
2112 ms |
79864 KB |
Output is correct |
40 |
Correct |
2708 ms |
79956 KB |
Output is correct |
41 |
Correct |
2735 ms |
79836 KB |
Output is correct |
42 |
Correct |
2739 ms |
79948 KB |
Output is correct |
43 |
Correct |
2700 ms |
10304 KB |
Output is correct |
44 |
Correct |
2945 ms |
10264 KB |
Output is correct |
45 |
Correct |
1025 ms |
10156 KB |
Output is correct |
46 |
Correct |
2908 ms |
10184 KB |
Output is correct |
47 |
Correct |
2735 ms |
10408 KB |
Output is correct |
48 |
Correct |
3844 ms |
10428 KB |
Output is correct |
49 |
Correct |
4075 ms |
10372 KB |
Output is correct |
50 |
Correct |
4100 ms |
10380 KB |
Output is correct |
51 |
Correct |
3956 ms |
10348 KB |
Output is correct |
52 |
Correct |
3554 ms |
17012 KB |
Output is correct |
53 |
Correct |
3584 ms |
16724 KB |
Output is correct |
54 |
Correct |
3943 ms |
16820 KB |
Output is correct |
55 |
Correct |
4895 ms |
16560 KB |
Output is correct |
56 |
Correct |
4699 ms |
16508 KB |
Output is correct |
57 |
Correct |
4900 ms |
16860 KB |
Output is correct |
58 |
Correct |
2782 ms |
12496 KB |
Output is correct |
59 |
Correct |
2782 ms |
12556 KB |
Output is correct |
60 |
Correct |
2355 ms |
79952 KB |
Output is correct |
61 |
Correct |
2745 ms |
79924 KB |
Output is correct |
62 |
Correct |
2861 ms |
79956 KB |
Output is correct |
63 |
Correct |
2809 ms |
79956 KB |
Output is correct |
64 |
Correct |
734 ms |
10068 KB |
Output is correct |
65 |
Correct |
1171 ms |
44372 KB |
Output is correct |
66 |
Correct |
1178 ms |
44372 KB |
Output is correct |
67 |
Correct |
2793 ms |
66132 KB |
Output is correct |
68 |
Correct |
3581 ms |
66156 KB |
Output is correct |
69 |
Correct |
3477 ms |
66048 KB |
Output is correct |
70 |
Correct |
3599 ms |
66132 KB |
Output is correct |