Submission #1100047

# Submission time Handle Problem Language Result Execution time Memory
1100047 2024-10-12T15:13:02 Z modwwe Sushi (JOI16_sushi) C++17
100 / 100
5185 ms 153004 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
    }
}

//6 0 0 0 6 0 0

Compilation message

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<long long int>)':
sushi.cpp:93:23: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long 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 112 ms 604 KB Output is correct
2 Correct 111 ms 604 KB Output is correct
3 Correct 111 ms 672 KB Output is correct
4 Correct 111 ms 604 KB Output is correct
5 Correct 111 ms 644 KB Output is correct
6 Correct 112 ms 604 KB Output is correct
7 Correct 34 ms 604 KB Output is correct
8 Correct 33 ms 604 KB Output is correct
9 Correct 112 ms 676 KB Output is correct
10 Correct 114 ms 676 KB Output is correct
11 Correct 106 ms 604 KB Output is correct
12 Correct 105 ms 604 KB Output is correct
13 Correct 120 ms 604 KB Output is correct
14 Correct 119 ms 604 KB Output is correct
15 Correct 126 ms 604 KB Output is correct
16 Correct 54 ms 604 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 1 ms 604 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2769 ms 152812 KB Output is correct
2 Correct 2712 ms 151336 KB Output is correct
3 Correct 702 ms 149284 KB Output is correct
4 Correct 2631 ms 152880 KB Output is correct
5 Correct 2302 ms 152872 KB Output is correct
6 Correct 2847 ms 152928 KB Output is correct
7 Correct 2978 ms 152856 KB Output is correct
8 Correct 2940 ms 152816 KB Output is correct
9 Correct 704 ms 149280 KB Output is correct
10 Correct 2105 ms 151464 KB Output is correct
11 Correct 682 ms 149276 KB Output is correct
12 Correct 2119 ms 151332 KB Output is correct
13 Correct 2586 ms 153004 KB Output is correct
14 Correct 2696 ms 151468 KB Output is correct
15 Correct 727 ms 149348 KB Output is correct
16 Correct 2680 ms 152872 KB Output is correct
17 Correct 2327 ms 152920 KB Output is correct
18 Correct 2991 ms 152872 KB Output is correct
19 Correct 2983 ms 152868 KB Output is correct
20 Correct 2926 ms 152872 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 112 ms 604 KB Output is correct
2 Correct 111 ms 604 KB Output is correct
3 Correct 111 ms 672 KB Output is correct
4 Correct 111 ms 604 KB Output is correct
5 Correct 111 ms 644 KB Output is correct
6 Correct 112 ms 604 KB Output is correct
7 Correct 34 ms 604 KB Output is correct
8 Correct 33 ms 604 KB Output is correct
9 Correct 112 ms 676 KB Output is correct
10 Correct 114 ms 676 KB Output is correct
11 Correct 106 ms 604 KB Output is correct
12 Correct 105 ms 604 KB Output is correct
13 Correct 120 ms 604 KB Output is correct
14 Correct 119 ms 604 KB Output is correct
15 Correct 126 ms 604 KB Output is correct
16 Correct 54 ms 604 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 1 ms 604 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 2769 ms 152812 KB Output is correct
24 Correct 2712 ms 151336 KB Output is correct
25 Correct 702 ms 149284 KB Output is correct
26 Correct 2631 ms 152880 KB Output is correct
27 Correct 2302 ms 152872 KB Output is correct
28 Correct 2847 ms 152928 KB Output is correct
29 Correct 2978 ms 152856 KB Output is correct
30 Correct 2940 ms 152816 KB Output is correct
31 Correct 704 ms 149280 KB Output is correct
32 Correct 2105 ms 151464 KB Output is correct
33 Correct 682 ms 149276 KB Output is correct
34 Correct 2119 ms 151332 KB Output is correct
35 Correct 2586 ms 153004 KB Output is correct
36 Correct 2696 ms 151468 KB Output is correct
37 Correct 727 ms 149348 KB Output is correct
38 Correct 2680 ms 152872 KB Output is correct
39 Correct 2327 ms 152920 KB Output is correct
40 Correct 2991 ms 152872 KB Output is correct
41 Correct 2983 ms 152868 KB Output is correct
42 Correct 2926 ms 152872 KB Output is correct
43 Correct 2819 ms 24612 KB Output is correct
44 Correct 2839 ms 24660 KB Output is correct
45 Correct 1092 ms 21336 KB Output is correct
46 Correct 3004 ms 24844 KB Output is correct
47 Correct 2866 ms 24952 KB Output is correct
48 Correct 3728 ms 24916 KB Output is correct
49 Correct 4356 ms 24960 KB Output is correct
50 Correct 4265 ms 24812 KB Output is correct
51 Correct 4266 ms 24972 KB Output is correct
52 Correct 3911 ms 37460 KB Output is correct
53 Correct 4090 ms 36520 KB Output is correct
54 Correct 4233 ms 36920 KB Output is correct
55 Correct 5185 ms 36696 KB Output is correct
56 Correct 4828 ms 36516 KB Output is correct
57 Correct 5087 ms 36436 KB Output is correct
58 Correct 3066 ms 28332 KB Output is correct
59 Correct 2870 ms 28500 KB Output is correct
60 Correct 2519 ms 152876 KB Output is correct
61 Correct 2970 ms 152824 KB Output is correct
62 Correct 3214 ms 152912 KB Output is correct
63 Correct 3363 ms 152864 KB Output is correct
64 Correct 796 ms 21332 KB Output is correct
65 Correct 1274 ms 89848 KB Output is correct
66 Correct 1333 ms 89940 KB Output is correct
67 Correct 3114 ms 124904 KB Output is correct
68 Correct 3647 ms 125016 KB Output is correct
69 Correct 3464 ms 124936 KB Output is correct
70 Correct 3662 ms 124980 KB Output is correct