Submission #1196749
Source Code Expand
#include<bits/stdc++.h> #define X first #define Y second using namespace std; typedef long long ll; const ll mod = 1e9+7; ll n, cc, x, y, a[100005], b[100005], fac[100005], ans = 1; vector<pair<ll, ll> > grp[200005]; priority_queue<pair<ll, ll> > pq; ll calc (ll X, ll Y) { if(!Y) return 1; ll ret = calc(X, Y/2); ret = (ret * ret) % mod; if(Y&1) ret = (ret * X) % mod; return ret; } int main() { scanf("%lld%lld%lld",&n,&x,&y); for(int i=1;i<=n;i++) { scanf("%lld%lld",&a[i],&b[i]); grp[a[i]].push_back({b[i], a[i]}); cc = max(cc, a[i]); } for(int i=1;i<=cc;i++) { if(grp[i].empty()) continue; sort(grp[i].begin(), grp[i].end()); while(grp[i].size() > 1) { if(grp[i].back().X + grp[i][0].X > x) { grp[++cc].push_back(grp[i].back()); grp[i].pop_back(); } else break; } pq.push({-grp[i][0].X, i}); } ll idx = pq.top().Y; pq.pop(); while(!pq.empty()) { ll cur = pq.top().Y; pq.pop(); if(grp[cur][0].X + grp[idx][0].X > y) break; while(grp[cur].size()) { grp[idx].push_back(grp[cur].back()); grp[cur].pop_back(); } } fac[0] = 1; for(int i=1;i<=n;i++) fac[i] = fac[i-1] * i % mod; for(int i=1;i<=cc;i++) { if(grp[i].empty()) continue; for(int j=0;j<grp[i].size();j++) swap(grp[i][j].X, grp[i][j].Y); sort(grp[i].begin(), grp[i].end()); ans = (ans * fac[grp[i].size()]) % mod; ll cur = 1; for(int j=1;j<grp[i].size();j++) { if(grp[i][j].X != grp[i][j-1].X) { ans = (ans * calc(fac[cur], mod-2)) % mod; cur = 1; } else cur++; } ans = (ans * calc(fac[cur], mod-2)) % mod; } printf("%lld\n",ans); }
Submission Info
Submission Time | |
---|---|
Task | D - Colorful Balls |
User | khsoo01 |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 1657 Byte |
Status | RE |
Exec Time | 171 ms |
Memory | 15088 KB |
Compile Error
./Main.cpp: In function ‘int main()’: ./Main.cpp:21:32: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] scanf("%lld%lld%lld",&n,&x,&y); ^ ./Main.cpp:23:32: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] scanf("%lld%lld",&a[i],&b[i]); ^
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 | 3 ms | 6400 KB |
00_example_02.txt | AC | 4 ms | 6400 KB |
00_example_03.txt | AC | 3 ms | 6400 KB |
01.txt | AC | 4 ms | 6400 KB |
02.txt | AC | 4 ms | 6400 KB |
03.txt | AC | 8 ms | 6912 KB |
04.txt | AC | 4 ms | 6400 KB |
05.txt | AC | 6 ms | 6656 KB |
06.txt | AC | 4 ms | 6400 KB |
07.txt | AC | 67 ms | 14952 KB |
08.txt | AC | 4 ms | 6400 KB |
09.txt | AC | 28 ms | 10516 KB |
10.txt | AC | 20 ms | 8700 KB |
11.txt | AC | 4 ms | 6400 KB |
12.txt | AC | 4 ms | 6400 KB |
13.txt | AC | 8 ms | 7040 KB |
14.txt | AC | 4 ms | 6400 KB |
15.txt | AC | 31 ms | 9512 KB |
16.txt | AC | 74 ms | 14320 KB |
17.txt | AC | 12 ms | 7488 KB |
18.txt | AC | 24 ms | 9336 KB |
19.txt | AC | 58 ms | 14576 KB |
20.txt | RE | 170 ms | 13480 KB |
21.txt | RE | 126 ms | 10112 KB |
22.txt | WA | 43 ms | 11048 KB |
23.txt | RE | 135 ms | 10112 KB |
24.txt | WA | 80 ms | 13852 KB |
25.txt | WA | 58 ms | 12196 KB |
26.txt | RE | 128 ms | 10112 KB |
27.txt | RE | 125 ms | 10112 KB |
28.txt | RE | 126 ms | 10112 KB |
29.txt | WA | 61 ms | 12464 KB |
30.txt | RE | 171 ms | 13608 KB |
31.txt | RE | 125 ms | 10112 KB |
32.txt | RE | 127 ms | 10112 KB |
33.txt | RE | 125 ms | 10112 KB |
34.txt | RE | 124 ms | 10368 KB |
35.txt | WA | 45 ms | 11580 KB |
36.txt | RE | 128 ms | 9856 KB |
37.txt | RE | 124 ms | 11136 KB |
38.txt | RE | 122 ms | 9472 KB |
39.txt | RE | 123 ms | 9600 KB |
40.txt | RE | 123 ms | 10368 KB |
41.txt | RE | 123 ms | 10368 KB |
42.txt | RE | 122 ms | 10368 KB |
43.txt | RE | 123 ms | 10368 KB |
44.txt | WA | 72 ms | 13808 KB |
45.txt | WA | 71 ms | 13680 KB |
46.txt | RE | 123 ms | 10368 KB |
47.txt | WA | 51 ms | 12400 KB |
48.txt | RE | 120 ms | 9076 KB |
49.txt | RE | 128 ms | 9076 KB |
50.txt | WA | 61 ms | 15088 KB |
51.txt | WA | 62 ms | 15088 KB |
52.txt | WA | 66 ms | 14960 KB |
53.txt | WA | 66 ms | 15088 KB |
54.txt | WA | 66 ms | 14960 KB |