Submission #1887472
Source Code Expand
#define _CRT_SECURE_NO_WARNINGS #include <iostream> #include <sstream> #include <iomanip> #include <cstdio> #include <cstdlib> #include <cmath> #include <cctype> #include <cstring> #include <vector> #include <list> #include <queue> #include <deque> #include <stack> #include <map> #include <set> #include <algorithm> #include <iterator> #include <bitset> #include <ctime> #include<complex> using namespace std; #define FOR(i,a,b) for (int i = (a); i < (b); i++) #define RFOR(i,b,a) for (int i = (b)-1; i >= (a); i--) #define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++) #define FILL(a,value) memset(a, value, sizeof(a)) #define SZ(a) (int)a.size() #define ALL(a) a.begin(), a.end() #define PB push_back #define MP make_pair typedef long long LL; typedef vector<int> VI; typedef pair<int, int> PII; const double PI = acos(-1.0); const int INF = 1000 * 1000 * 1000 + 7; const LL LINF = INF * (LL)INF; const int MAX = 4 * 1000 * 100 + 47; const int MOD = 1000 * 1000 * 1000 + 7; int n, x, y; PII A[MAX]; LL F[MAX]; LL FR[MAX]; map<int, int> M; int C[MAX]; int P[MAX]; int U[MAX]; LL bp(LL a, int n) { LL res = 1; while (n) { if (n & 1) res = (res * a) % MOD; a = (a * a) % MOD; n >>= 1; } return res; } LL inv(LL a) { return bp(a, MOD - 2); } int main() { //freopen("in.txt", "r", stdin); //freopen("out.txt", "w", stdout); ios::sync_with_stdio(false); cin.tie(0); F[0] = FR[0] = 1; FOR(i, 1, MAX) { F[i] = (F[i - 1] * i) % MOD; FR[i] = inv(F[i]); } cin >> n >> x >> y; FOR(i, 0, n) { cin >> A[i].second >> A[i].first; } sort(A, A + n); FILL(C, -1); FOR(i, 0, n) { int c = A[i].second; P[i] = C[c]; if (C[c] == -1) C[c] = i; } U[0] = 1; M[A[0].second]++; int p = -1; FOR(i, 0, n) { if (A[i].second != A[0].second) { p = i; break; } } FOR(i, 1, n) { if (A[i].second == A[0].second) { if (A[i].first + A[0].first <= x || (p != -1 && U[p] && A[i].first + A[p].first <= y)) { M[A[i].second]++; U[i] = 1; } continue; } if (A[i].first + A[0].first <= y || (P[i] != -1 && A[i].first + A[P[i]].first <= x && U[i])) { M[A[i].second]++; U[i] = 1; } } int all = 0; LL res = 1; for (auto it = M.begin(); it != M.end(); it++) { all += it->second; res = (res * FR[it->second]) % MOD; } res = (res * F[all]) % MOD; cout << res << endl; }
Submission Info
Submission Time | |
---|---|
Task | D - Colorful Balls |
User | vjudge2 |
Language | C++14 (Clang 3.8.0) |
Score | 0 |
Code Size | 2378 Byte |
Status | WA |
Exec Time | 458 ms |
Memory | 18432 KB |
Judge Result
Set Name | Sample | All | ||||||
---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 1000 | ||||||
Status |
|
|
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 | 54 ms | 10744 KB |
00_example_02.txt | AC | 53 ms | 10496 KB |
00_example_03.txt | AC | 52 ms | 10496 KB |
01.txt | AC | 53 ms | 10496 KB |
02.txt | AC | 53 ms | 10496 KB |
03.txt | AC | 64 ms | 10752 KB |
04.txt | AC | 53 ms | 10496 KB |
05.txt | AC | 57 ms | 10624 KB |
06.txt | AC | 53 ms | 10624 KB |
07.txt | AC | 223 ms | 13056 KB |
08.txt | WA | 54 ms | 10496 KB |
09.txt | AC | 142 ms | 11264 KB |
10.txt | AC | 108 ms | 11136 KB |
11.txt | AC | 53 ms | 10496 KB |
12.txt | AC | 53 ms | 10496 KB |
13.txt | AC | 65 ms | 10752 KB |
14.txt | AC | 52 ms | 10496 KB |
15.txt | AC | 125 ms | 12160 KB |
16.txt | AC | 220 ms | 12416 KB |
17.txt | AC | 79 ms | 10880 KB |
18.txt | AC | 122 ms | 11136 KB |
19.txt | AC | 205 ms | 11776 KB |
20.txt | WA | 410 ms | 15744 KB |
21.txt | AC | 412 ms | 15744 KB |
22.txt | WA | 395 ms | 13440 KB |
23.txt | AC | 435 ms | 17920 KB |
24.txt | WA | 397 ms | 13568 KB |
25.txt | WA | 411 ms | 15488 KB |
26.txt | AC | 456 ms | 18176 KB |
27.txt | AC | 406 ms | 12032 KB |
28.txt | AC | 456 ms | 18304 KB |
29.txt | WA | 445 ms | 17024 KB |
30.txt | WA | 406 ms | 12800 KB |
31.txt | AC | 458 ms | 18304 KB |
32.txt | WA | 411 ms | 13696 KB |
33.txt | AC | 456 ms | 18048 KB |
34.txt | WA | 429 ms | 17280 KB |
35.txt | AC | 413 ms | 12672 KB |
36.txt | WA | 410 ms | 13056 KB |
37.txt | AC | 428 ms | 12672 KB |
38.txt | AC | 411 ms | 12672 KB |
39.txt | WA | 424 ms | 12416 KB |
40.txt | WA | 434 ms | 18432 KB |
41.txt | WA | 407 ms | 15872 KB |
42.txt | AC | 405 ms | 16000 KB |
43.txt | WA | 387 ms | 13440 KB |
44.txt | AC | 429 ms | 18432 KB |
45.txt | WA | 389 ms | 13568 KB |
46.txt | WA | 403 ms | 15616 KB |
47.txt | AC | 367 ms | 12544 KB |
48.txt | AC | 378 ms | 12288 KB |
49.txt | AC | 380 ms | 12544 KB |
50.txt | WA | 355 ms | 14464 KB |
51.txt | WA | 365 ms | 12032 KB |
52.txt | AC | 339 ms | 12544 KB |
53.txt | WA | 339 ms | 12544 KB |
54.txt | WA | 336 ms | 12544 KB |