Submission #1195873


Source Code Expand

#include <bits/stdc++.h>

#define FI(i,a,b) for(int i=(a);i<=(b);i++)
#define FD(i,a,b) for(int i=(a);i>=(b);i--)

#define LL long long
#define Ldouble long double
#define PI 3.1415926535897932384626

#define PII pair<int,int>
#define PLL pair<LL,LL>
#define mp make_pair
#define fi first
#define se second

#define INF 1000000005
#define mod 1000000007

using namespace std;

int n, x, y, gmc = INF;
vector<int> v[200005];

int ans = 1;
int fact[200005], inv[200005];

int po(int a, int b){
	int c = 1, d = a;
	while(b){
		if(b & 1) c = 1LL * c * d % mod;
		d = 1LL * d * d % mod;
		b >>= 1;
	}
	return c;
}

vector<int> u;

int main(){
	fact[0] = inv[0] = 1;
	FI(i, 1, 200000){
		fact[i] = 1LL * fact[i - 1] * i % mod;
		inv[i] = po(fact[i], mod - 2);
	}
	
	scanf("%d %d %d", &n, &x, &y);
	FI(i, 1, n){
		int a, b;
		scanf("%d %d", &a, &b);
		gmc = min(gmc, b);
		v[a].push_back(b);
	}
	FI(i, 1, n){
		int sz = v[i].size();
		if(sz){
			sort(v[i].begin(), v[i].end());
			if(v[i][0] + gmc > y){
				//this color not mobile
				continue;
			}
			else{
				//this color mobile
				int c = 1;
				FI(j, 1, sz - 1){
					if(v[i][j] + v[i][0] <= x) c++;
					else if(v[i][j] + gmc <= y) c++;
					else break;
				}
				u.push_back(c);
			}
		}
	}
	
	int summ = 0, sz = u.size();
	FI(i, 0, sz - 1) summ += u[i];
	ans = fact[summ];
	FI(i, 0, sz - 1) ans = 1LL * ans * inv[u[i]] % mod;
	printf("%d\n", ans);
	return 0;
}

Submission Info

Submission Time
Task D - Colorful Balls
User alex20030190
Language C++14 (GCC 5.4.1)
Score 0
Code Size 1495 Byte
Status WA
Exec Time 92 ms
Memory 11520 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:46:31: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d %d", &n, &x, &y);
                               ^
./Main.cpp:49:25: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d %d", &a, &b);
                         ^

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 1000
Status
AC × 3
AC × 54
WA × 3
Set Name Test Cases
Sample 00_example_01.txt, 00_example_02.txt, 00_example_03.txt
All 00_example_01.txt, 00_example_02.txt, 00_example_03.txt, 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, 24.txt, 25.txt, 26.txt, 27.txt, 28.txt, 29.txt, 30.txt, 31.txt, 32.txt, 33.txt, 34.txt, 35.txt, 36.txt, 37.txt, 38.txt, 39.txt, 40.txt, 41.txt, 42.txt, 43.txt, 44.txt, 45.txt, 46.txt, 47.txt, 48.txt, 49.txt, 50.txt, 51.txt, 52.txt, 53.txt, 54.txt
Case Name Status Exec Time Memory
00_example_01.txt AC 34 ms 6528 KB
00_example_02.txt AC 34 ms 6528 KB
00_example_03.txt AC 34 ms 6528 KB
01.txt AC 35 ms 6528 KB
02.txt AC 35 ms 6528 KB
03.txt AC 36 ms 6656 KB
04.txt AC 34 ms 6528 KB
05.txt AC 35 ms 6528 KB
06.txt AC 34 ms 6528 KB
07.txt AC 59 ms 7936 KB
08.txt AC 35 ms 6528 KB
09.txt AC 47 ms 6912 KB
10.txt AC 43 ms 6912 KB
11.txt AC 34 ms 6528 KB
12.txt AC 34 ms 6528 KB
13.txt AC 36 ms 6656 KB
14.txt AC 34 ms 6528 KB
15.txt AC 45 ms 7552 KB
16.txt AC 60 ms 7808 KB
17.txt AC 38 ms 6656 KB
18.txt AC 44 ms 6912 KB
19.txt AC 55 ms 7296 KB
20.txt AC 91 ms 11132 KB
21.txt AC 91 ms 11132 KB
22.txt AC 90 ms 10624 KB
23.txt AC 91 ms 11136 KB
24.txt AC 90 ms 10752 KB
25.txt AC 91 ms 11136 KB
26.txt AC 92 ms 11132 KB
27.txt AC 91 ms 10496 KB
28.txt AC 92 ms 11136 KB
29.txt AC 92 ms 11132 KB
30.txt AC 91 ms 10624 KB
31.txt AC 92 ms 11136 KB
32.txt AC 92 ms 10752 KB
33.txt AC 92 ms 11136 KB
34.txt AC 87 ms 10364 KB
35.txt WA 77 ms 7680 KB
36.txt AC 84 ms 8192 KB
37.txt WA 78 ms 7808 KB
38.txt WA 77 ms 7680 KB
39.txt AC 79 ms 7680 KB
40.txt AC 86 ms 11004 KB
41.txt AC 87 ms 11516 KB
42.txt AC 87 ms 11520 KB
43.txt AC 86 ms 11136 KB
44.txt AC 87 ms 11516 KB
45.txt AC 86 ms 11136 KB
46.txt AC 89 ms 11520 KB
47.txt AC 81 ms 7672 KB
48.txt AC 82 ms 7672 KB
49.txt AC 82 ms 7672 KB
50.txt AC 76 ms 10488 KB
51.txt AC 76 ms 9976 KB
52.txt AC 76 ms 7416 KB
53.txt AC 76 ms 7416 KB
54.txt AC 76 ms 7416 KB