Submission #1196781
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[200005], b[200005], fac[200005], ans = 1; vector<pair<ll, ll> > grp[400005]; 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 | WA |
Exec Time | 176 ms |
Memory | 34804 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 | 5 ms | 12544 KB |
00_example_02.txt | AC | 5 ms | 12544 KB |
00_example_03.txt | AC | 5 ms | 12544 KB |
01.txt | AC | 5 ms | 12544 KB |
02.txt | AC | 5 ms | 12544 KB |
03.txt | AC | 9 ms | 13056 KB |
04.txt | AC | 5 ms | 12544 KB |
05.txt | AC | 7 ms | 12800 KB |
06.txt | AC | 5 ms | 12544 KB |
07.txt | AC | 66 ms | 20968 KB |
08.txt | AC | 5 ms | 12544 KB |
09.txt | AC | 29 ms | 16660 KB |
10.txt | AC | 21 ms | 14844 KB |
11.txt | AC | 5 ms | 12544 KB |
12.txt | AC | 5 ms | 12544 KB |
13.txt | AC | 10 ms | 13184 KB |
14.txt | AC | 5 ms | 12544 KB |
15.txt | AC | 32 ms | 15656 KB |
16.txt | AC | 73 ms | 20336 KB |
17.txt | AC | 12 ms | 13632 KB |
18.txt | AC | 25 ms | 15480 KB |
19.txt | AC | 58 ms | 20592 KB |
20.txt | AC | 148 ms | 27056 KB |
21.txt | AC | 166 ms | 28524 KB |
22.txt | AC | 147 ms | 25692 KB |
23.txt | AC | 169 ms | 32240 KB |
24.txt | AC | 148 ms | 27632 KB |
25.txt | AC | 140 ms | 26260 KB |
26.txt | AC | 176 ms | 32492 KB |
27.txt | AC | 117 ms | 21760 KB |
28.txt | AC | 158 ms | 31896 KB |
29.txt | AC | 152 ms | 30752 KB |
30.txt | AC | 159 ms | 26992 KB |
31.txt | AC | 164 ms | 32208 KB |
32.txt | AC | 142 ms | 25276 KB |
33.txt | AC | 156 ms | 29728 KB |
34.txt | AC | 144 ms | 27252 KB |
35.txt | WA | 101 ms | 34804 KB |
36.txt | AC | 95 ms | 26608 KB |
37.txt | WA | 102 ms | 33792 KB |
38.txt | WA | 100 ms | 33772 KB |
39.txt | AC | 82 ms | 26640 KB |
40.txt | AC | 151 ms | 29040 KB |
41.txt | AC | 144 ms | 27248 KB |
42.txt | AC | 158 ms | 28272 KB |
43.txt | AC | 134 ms | 26612 KB |
44.txt | AC | 168 ms | 32240 KB |
45.txt | AC | 140 ms | 26228 KB |
46.txt | AC | 141 ms | 27120 KB |
47.txt | AC | 86 ms | 23020 KB |
48.txt | AC | 103 ms | 25580 KB |
49.txt | AC | 95 ms | 24300 KB |
50.txt | AC | 115 ms | 29676 KB |
51.txt | AC | 104 ms | 26352 KB |
52.txt | AC | 91 ms | 24048 KB |
53.txt | AC | 91 ms | 24048 KB |
54.txt | AC | 91 ms | 24048 KB |