Submission #1125802

#TimeUsernameProblemLanguageResultExecution timeMemory
1125802modwwe즐거운 사진 수집 (JOI13_collecting)C++17
100 / 100
1113 ms60980 KiB
#pragma GCC optimize("Ofast,unroll-loops")
#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 "db"
#define fin(x) freopen(x".inp","r",stdin)
#define fou(x) freopen(x".out","w",stdout)
#define pb push_back
#define mask(k) (1<<k)
#define mp make_pair
#define checktime   cerr << (double)clock() / CLOCKS_PER_SEC * 1000  << " ms";
using namespace std;
void phongbeo();
const int inf = 1e16;
const ll mod2 = 1e9+9999;
const int  mod1 = 998244353;
const ll base=67;
int add(int x,int y)
{
    if(x+y>=mod2) x-=mod2;
    if(x+y<0)x+=mod2;
    return x+y;
}
struct icd
{
    long double a;
    int b;
};
struct ib
{
    int a;
    int b;
};
struct ic
{
    ll a;
    int  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, mid, l2, r2, center;
int  i, s10, s12,k1,k2,k3,s11,lim,w,l,r ;
int kk;
int el = 19;
main()
{
    if(fopen(task".inp","r"))
    {
        fin(task);
        fou(task);
    }
    NHP
    ///  cin>>s1;
    // modwwe
    phongbeo();
//   checktime
}
int des[mask(20)];
struct ff
{
    int n;
    int c[20];
    int t[mask(22)+1];
    void build(int node,int l,int r)
    {
        t[node]=0;
        c[des[r-l]]++;
        if(l==r)return;
        int mid=l+r>>1;
        build(node<<1,l,mid);
        build(node<<1|1,mid+1,r);
    }
    void upd(int node,int l,int r,int l1)
    {
        if(t[node]!=-1)
            c[des[r-l]]--;
        if(l==r)
        {
            t[node]=(t[node]^1);
            c[des[r-l]]++;
            return;
        }
        int mid=l+r>>1;
        if(l1<=mid)
            upd(node<<1,l,mid,l1);
        else
            upd(node<<1|1,mid+1,r,l1);
        t[node]=-1;
        if(t[node<<1]==t[node<<1|1])t[node]=t[node<<1];
        if(t[node]!=-1)
            c[des[r-l]]++;
    }
    void upd(int x)
    {
        upd(1,1,n,x);
    }
    void init(int sz)
    {
        n=sz;
        build(1,1,n);
    }
} st[2];
void phongbeo()
{
    cin>>n>>m;
    for(int i=0; i<=n; i++)
        des[mask(i)-1]=i;
    st[0].init(mask(n));
    st[1].init(mask(n));
    while(m--)
    {
        cin>>l>>r;
        st[l].upd(r);
        s4=0;
        for(int i=0; i<=n; i++)
        {
            s4+=(1ll<<(i<<1));
            s4-=st[0].c[i]*st[1].c[i];
        }
        cout<<s4*4+1,down
    }
}

Compilation message (stderr)

collecting.cpp:58:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   58 | main()
      | ^~~~
collecting.cpp: In function 'int main()':
collecting.cpp:12:23: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 | #define fin(x) freopen(x".inp","r",stdin)
      |                ~~~~~~~^~~~~~~~~~~~~~~~~~~
collecting.cpp:62:9: note: in expansion of macro 'fin'
   62 |         fin(task);
      |         ^~~
collecting.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 fou(x) freopen(x".out","w",stdout)
      |                ~~~~~~~^~~~~~~~~~~~~~~~~~~~
collecting.cpp:63:9: note: in expansion of macro 'fou'
   63 |         fou(task);
      |         ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...