Submission #1100058

# Submission time Handle Problem Language Result Execution time Memory
1100058 2024-10-12T15:17:42 Z modwwe Sushi (JOI16_sushi) C++17
100 / 100
4676 ms 80208 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[650];
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)
    {
        if(!p.empty())
        for(int i=1; i<=sz; i++)
        {
            if(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[650];
int S=633 ;
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: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 115 ms 348 KB Output is correct
2 Correct 115 ms 348 KB Output is correct
3 Correct 120 ms 344 KB Output is correct
4 Correct 114 ms 348 KB Output is correct
5 Correct 116 ms 344 KB Output is correct
6 Correct 124 ms 552 KB Output is correct
7 Correct 37 ms 344 KB Output is correct
8 Correct 33 ms 348 KB Output is correct
9 Correct 120 ms 560 KB Output is correct
10 Correct 115 ms 344 KB Output is correct
11 Correct 110 ms 564 KB Output is correct
12 Correct 110 ms 564 KB Output is correct
13 Correct 129 ms 344 KB Output is correct
14 Correct 128 ms 564 KB Output is correct
15 Correct 129 ms 552 KB Output is correct
16 Correct 52 ms 348 KB Output is correct
17 Correct 0 ms 344 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 1 ms 344 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 2410 ms 79952 KB Output is correct
2 Correct 2349 ms 79928 KB Output is correct
3 Correct 606 ms 79844 KB Output is correct
4 Correct 2107 ms 79956 KB Output is correct
5 Correct 2094 ms 79952 KB Output is correct
6 Correct 2870 ms 80148 KB Output is correct
7 Correct 2691 ms 79952 KB Output is correct
8 Correct 2857 ms 79916 KB Output is correct
9 Correct 630 ms 79700 KB Output is correct
10 Correct 2060 ms 79956 KB Output is correct
11 Correct 641 ms 79956 KB Output is correct
12 Correct 1853 ms 79952 KB Output is correct
13 Correct 2294 ms 79956 KB Output is correct
14 Correct 2415 ms 80068 KB Output is correct
15 Correct 711 ms 79892 KB Output is correct
16 Correct 2140 ms 80140 KB Output is correct
17 Correct 2080 ms 80128 KB Output is correct
18 Correct 2910 ms 80208 KB Output is correct
19 Correct 2825 ms 80136 KB Output is correct
20 Correct 2863 ms 80000 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 115 ms 348 KB Output is correct
2 Correct 115 ms 348 KB Output is correct
3 Correct 120 ms 344 KB Output is correct
4 Correct 114 ms 348 KB Output is correct
5 Correct 116 ms 344 KB Output is correct
6 Correct 124 ms 552 KB Output is correct
7 Correct 37 ms 344 KB Output is correct
8 Correct 33 ms 348 KB Output is correct
9 Correct 120 ms 560 KB Output is correct
10 Correct 115 ms 344 KB Output is correct
11 Correct 110 ms 564 KB Output is correct
12 Correct 110 ms 564 KB Output is correct
13 Correct 129 ms 344 KB Output is correct
14 Correct 128 ms 564 KB Output is correct
15 Correct 129 ms 552 KB Output is correct
16 Correct 52 ms 348 KB Output is correct
17 Correct 0 ms 344 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 1 ms 344 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 2410 ms 79952 KB Output is correct
24 Correct 2349 ms 79928 KB Output is correct
25 Correct 606 ms 79844 KB Output is correct
26 Correct 2107 ms 79956 KB Output is correct
27 Correct 2094 ms 79952 KB Output is correct
28 Correct 2870 ms 80148 KB Output is correct
29 Correct 2691 ms 79952 KB Output is correct
30 Correct 2857 ms 79916 KB Output is correct
31 Correct 630 ms 79700 KB Output is correct
32 Correct 2060 ms 79956 KB Output is correct
33 Correct 641 ms 79956 KB Output is correct
34 Correct 1853 ms 79952 KB Output is correct
35 Correct 2294 ms 79956 KB Output is correct
36 Correct 2415 ms 80068 KB Output is correct
37 Correct 711 ms 79892 KB Output is correct
38 Correct 2140 ms 80140 KB Output is correct
39 Correct 2080 ms 80128 KB Output is correct
40 Correct 2910 ms 80208 KB Output is correct
41 Correct 2825 ms 80136 KB Output is correct
42 Correct 2863 ms 80000 KB Output is correct
43 Correct 2784 ms 10656 KB Output is correct
44 Correct 2804 ms 10368 KB Output is correct
45 Correct 935 ms 10328 KB Output is correct
46 Correct 2764 ms 10324 KB Output is correct
47 Correct 2787 ms 10272 KB Output is correct
48 Correct 3436 ms 10224 KB Output is correct
49 Correct 3950 ms 10324 KB Output is correct
50 Correct 4002 ms 10404 KB Output is correct
51 Correct 3863 ms 10324 KB Output is correct
52 Correct 3549 ms 17416 KB Output is correct
53 Correct 3429 ms 16720 KB Output is correct
54 Correct 4214 ms 16664 KB Output is correct
55 Correct 4602 ms 16504 KB Output is correct
56 Correct 4676 ms 16724 KB Output is correct
57 Correct 4670 ms 16836 KB Output is correct
58 Correct 2872 ms 12436 KB Output is correct
59 Correct 2780 ms 12496 KB Output is correct
60 Correct 2273 ms 80124 KB Output is correct
61 Correct 2857 ms 79900 KB Output is correct
62 Correct 2775 ms 79956 KB Output is correct
63 Correct 2745 ms 80136 KB Output is correct
64 Correct 707 ms 10100 KB Output is correct
65 Correct 1292 ms 44308 KB Output is correct
66 Correct 1267 ms 44316 KB Output is correct
67 Correct 2699 ms 65876 KB Output is correct
68 Correct 3640 ms 66056 KB Output is correct
69 Correct 3608 ms 65956 KB Output is correct
70 Correct 3459 ms 65896 KB Output is correct