Submission #6698669


Source Code Expand

Copy
#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;

using _loop_int = int;
#define REP(i,n) for(_loop_int i=0; i<(_loop_int)(n); i++)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a); i<(_loop_int)(b); i++)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1; i>=(_loop_int)(a); i--)

#define CHMIN(a,b) (a)=min((a),(b))
#define CHMAX(a,b) (a)=max((a),(b))
#define ALL(v) (v).begin(),(v).end()

#define DEBUG(x) cerr<<#x<<": "<<(x)<<endl
#define DEBUG_VEC(v) cerr<<#v<<": ";REP(__i,(v).size())cerr<<((v)[__i])<<", ";cerr<<endl

const ll MOD = 998244353ll;

int n;
int x[252521], y[252521];
int val[252521][4];
pii ps[252521];

const int N = 252521;
int bit[N+10];
void add(int a, int w){
    a++;
    for(int x=a; x<=N; x+=x&-x)bit[x]+=w;
}
int sum(int a){
    a++;
    int ret = 0;
    for(int x=a; x>0; x-=x&-x)ret+=bit[x];
    return ret;
}

vi xs, ys;

ll modpow(ll a, ll b){
    ll r=1;
    while(b){
        if(b&1)r=r*a%MOD;
        a=a*a%MOD;
        b>>=1;
    }
    return r;
}
ll modinv(ll a){
    return modpow(a,MOD-2);
}

int main(){
    scanf("%d",&n);
    REP(i,n)scanf("%d%d",x+i,y+i);
    // zaatu
    {
        set<int> X,Y;
        REP(i,n)X.insert(x[i]),Y.insert(y[i]);
        map<int,int> mx,my;
        int it=0;
        for(int x : X)mx[x]=it++;
        it = 0;
        for(int y : Y)my[y]=it++;
        REP(i,n)x[i]=mx[x[i]],y[i]=my[y[i]];
    }
    REP(i,n)ps[i] = pii(x[i],y[i]);
    sort(ps,ps+n);

    fill(bit,bit+N,0);
    REP(i,n){
        int cnt = sum(ps[i].second);
        val[i][0] = cnt;
        val[i][1] = i-cnt;
        add(ps[i].second,1);
    }
    fill(bit,bit+N,0);
    FORR(i,0,n){
        int cnt = sum(ps[i].second);
        val[i][3] = cnt;
        val[i][2] = (n-1-i)-cnt;
        add(ps[i].second,1);
    }

    ll ans = 0;
    ll mul = modpow(2,n-1);
    REP(i,n){
        ans += mul;
        ans %= MOD;
        REP(msk,1<<4){
            if(__builtin_popcount(msk)>=3){
                ll add = 1;
                REP(j,4)if(msk>>j&1){
                    int c = val[i][j];
                    add *= modpow(2,c)-1;
                    add %= MOD;
                }
                ans += add;
                ans %= MOD;
            }else if(msk==0b0101){
                ll add = 1;
                REP(j,4)if(j==0 || j==2){
                    int c = val[i][j];
                    add *= modpow(2,c)-1;
                    add %= MOD;
                }
                ans += add;
                ans %= MOD;
            }else if(msk==0b1010){
                ll add = 1;
                REP(j,4)if(j==1 || j==3){
                    int c = val[i][j];
                    add *= modpow(2,c)-1;
                    add %= MOD;
                }
                ans += add;
                ans %= MOD;
            }
        }
    }
    printf("%lld\n",ans);
    return 0;
}

Submission Info

Submission Time
Task F - Enclosed Points
User rickytheta
Language C++14 (GCC 5.4.1)
Score 600
Code Size 3082 Byte
Status AC
Exec Time 1084 ms
Memory 46464 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:59:19: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d",&n);
                   ^
./Main.cpp:60:34: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
     REP(i,n)scanf("%d%d",x+i,y+i);
                                  ^

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 600 / 600
Status
AC × 3
AC × 26
Set Name Test Cases
Sample s1.txt, s2.txt, s3.txt
All 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt, 19.txt, 20.txt, 21.txt, 22.txt, 23.txt, s1.txt, s2.txt, s3.txt
Case Name Status Exec Time Memory
01.txt AC 2 ms 5376 KB
02.txt AC 2 ms 5376 KB
03.txt AC 2 ms 5376 KB
04.txt AC 2 ms 5376 KB
05.txt AC 2 ms 5376 KB
06.txt AC 2 ms 5376 KB
07.txt AC 2 ms 5376 KB
08.txt AC 2 ms 5376 KB
09.txt AC 2 ms 5376 KB
10.txt AC 3 ms 5376 KB
11.txt AC 1059 ms 45824 KB
12.txt AC 1031 ms 45184 KB
13.txt AC 1074 ms 46336 KB
14.txt AC 1060 ms 44544 KB
15.txt AC 1084 ms 46464 KB
16.txt AC 1080 ms 46464 KB
17.txt AC 1077 ms 46464 KB
18.txt AC 1077 ms 46464 KB
19.txt AC 810 ms 46208 KB
20.txt AC 788 ms 45696 KB
21.txt AC 947 ms 46464 KB
22.txt AC 943 ms 46464 KB
23.txt AC 2 ms 5376 KB
s1.txt AC 2 ms 5376 KB
s2.txt AC 2 ms 5376 KB
s3.txt AC 2 ms 5376 KB