Submission #6735040


Source Code Expand

Copy
#include <bits/stdc++.h>
using namespace std;
typedef long long   signed int LL;
#define incID(i, l, r) for(LL i = (l)    ; i <  (r); ++i)
#define inc(i, n)  incID(i, 0, n)
#define FI first
#define SE second

// ---- ----

const int MOD = 998244353;

int n, BIT[200001];
pair<int, int> p[200000];
LL e2[200001];

int  sum(int i) { int s = 0; for(i++; i     ; i -= i & -i) { s += BIT[i]; } return s; }
void add(int i) {            for(i++; i <= n; i += i & -i) { BIT[i]++; } }

int main() {
	cin >> n;
	inc(i, n) { scanf("%d %d\n", &p[i].FI, &p[i].SE); }
	sort(p, p + n);
	inc(i, n) {
		p[i].FI = p[i].SE;
		p[i].SE = i;
	}
	sort(p, p + n);
	
	e2[0] = 1;
	inc(i, n) {
		e2[i + 1] = e2[i] << 1;
		if(e2[i + 1] >= MOD) { e2[i + 1] -= MOD; }
	}
	
	LL s = 0;
	inc(i, n) {
		int j = p[i].SE;
		
		int v = sum(j);
		add(j);
		LL a = e2[v];
		LL b = e2[i - v];
		LL c = e2[j - v];
		LL d = e2[n - 1 - (i + j - v)];
		s += (a + d - 1) * (b + c - 1) % MOD;
	}
	LL ans = (n * e2[n] - s) % MOD;
	if(ans < 0) { ans += MOD; }
	
	printf("%lld\n", ans);
	
	return 0;
}

Submission Info

Submission Time
Task F - Enclosed Points
User FF256grhy
Language C++14 (GCC 5.4.1)
Score 600
Code Size 1107 Byte
Status AC
Exec Time 87 ms
Memory 4096 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:22:50: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  inc(i, n) { scanf("%d %d\n", &p[i].FI, &p[i].SE); }
                                                  ^

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 1 ms 256 KB
02.txt AC 1 ms 256 KB
03.txt AC 1 ms 256 KB
04.txt AC 1 ms 256 KB
05.txt AC 1 ms 256 KB
06.txt AC 1 ms 256 KB
07.txt AC 1 ms 256 KB
08.txt AC 1 ms 256 KB
09.txt AC 1 ms 256 KB
10.txt AC 1 ms 256 KB
11.txt AC 85 ms 4096 KB
12.txt AC 84 ms 4096 KB
13.txt AC 86 ms 4096 KB
14.txt AC 82 ms 3968 KB
15.txt AC 86 ms 4096 KB
16.txt AC 87 ms 4096 KB
17.txt AC 86 ms 4096 KB
18.txt AC 86 ms 4096 KB
19.txt AC 70 ms 4096 KB
20.txt AC 69 ms 4096 KB
21.txt AC 76 ms 4096 KB
22.txt AC 76 ms 4096 KB
23.txt AC 1 ms 256 KB
s1.txt AC 1 ms 256 KB
s2.txt AC 1 ms 256 KB
s3.txt AC 1 ms 256 KB