Submission #1679529
Source Code Expand
#include <cstdio> const int N=200005,mo=1000000007; int a[N],b[N],c[N],w[N],cnt[N]; int ksm(int x,int y){ int i=1; for (;y;y>>=1,x=1ll*x*x%mo) if (y&1) i=1ll*i*x%mo; return i; } int main(){ int n,X,Y; scanf("%d%d%d",&n,&X,&Y); for (int i=0;i<=n;i++) a[i]=mo; for (int i=1;i<=n;i++){ scanf("%d%d",&c[i],&w[i]); if (w[i]<a[c[i]]) a[c[i]]=w[i],b[c[i]]=i; } int c1=0,c2=0; for (int i=1;i<=n;i++) if (a[i]<a[c1]) c2=c1,c1=i; else if (a[i]<a[c2]) c2=i; for (int i=1;i<=n;i++) if ((i!=c1 && w[i]+a[c1]<=Y)||(i!=c2 && w[i]+a[c2]<=Y)|| ((i==b[c[i]] || w[i]+a[c[i]]<=X) && a[c[i]]+a[c1]<=Y)) cnt[c[i]]++; int ans1=1,ans2=1; for (int i=1,j=0;i<=n;i++) for (int k=1;k<=cnt[i];k++){ ans1=1ll*ans1*(++j)%mo; ans2=1ll*ans2*k%mo; } ans1=1ll*ans1*ksm(ans2,mo-2)%mo; printf("%d\n",ans1); }
Submission Info
Submission Time | |
---|---|
Task | D - Colorful Balls |
User | aufeas |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 848 Byte |
Status | WA |
Exec Time | 50 ms |
Memory | 4096 KB |
Compile Error
./Main.cpp: In function ‘int main()’: ./Main.cpp:14:26: 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:17:28: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] scanf("%d%d",&c[i],&w[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 | 1 ms | 128 KB |
00_example_02.txt | AC | 1 ms | 128 KB |
00_example_03.txt | AC | 1 ms | 128 KB |
01.txt | AC | 1 ms | 128 KB |
02.txt | AC | 1 ms | 128 KB |
03.txt | AC | 2 ms | 256 KB |
04.txt | AC | 1 ms | 128 KB |
05.txt | AC | 1 ms | 256 KB |
06.txt | AC | 1 ms | 128 KB |
07.txt | AC | 20 ms | 1536 KB |
08.txt | AC | 1 ms | 128 KB |
09.txt | AC | 12 ms | 896 KB |
10.txt | AC | 7 ms | 640 KB |
11.txt | AC | 1 ms | 128 KB |
12.txt | AC | 1 ms | 128 KB |
13.txt | AC | 2 ms | 384 KB |
14.txt | AC | 1 ms | 128 KB |
15.txt | AC | 9 ms | 1024 KB |
16.txt | AC | 22 ms | 1664 KB |
17.txt | AC | 4 ms | 384 KB |
18.txt | AC | 9 ms | 768 KB |
19.txt | AC | 18 ms | 1280 KB |
20.txt | AC | 50 ms | 4096 KB |
21.txt | AC | 49 ms | 4096 KB |
22.txt | AC | 49 ms | 4096 KB |
23.txt | AC | 48 ms | 4096 KB |
24.txt | AC | 49 ms | 4096 KB |
25.txt | AC | 48 ms | 4096 KB |
26.txt | AC | 49 ms | 4096 KB |
27.txt | AC | 48 ms | 3328 KB |
28.txt | AC | 49 ms | 4096 KB |
29.txt | AC | 50 ms | 4096 KB |
30.txt | AC | 49 ms | 4096 KB |
31.txt | AC | 49 ms | 4096 KB |
32.txt | AC | 50 ms | 4096 KB |
33.txt | AC | 47 ms | 4096 KB |
34.txt | AC | 44 ms | 4096 KB |
35.txt | WA | 43 ms | 2944 KB |
36.txt | AC | 48 ms | 4096 KB |
37.txt | WA | 43 ms | 3712 KB |
38.txt | WA | 43 ms | 2816 KB |
39.txt | AC | 45 ms | 4096 KB |
40.txt | AC | 41 ms | 4096 KB |
41.txt | AC | 45 ms | 4096 KB |
42.txt | AC | 45 ms | 4096 KB |
43.txt | AC | 44 ms | 4096 KB |
44.txt | AC | 44 ms | 4096 KB |
45.txt | AC | 45 ms | 4096 KB |
46.txt | AC | 46 ms | 4096 KB |
47.txt | AC | 39 ms | 2560 KB |
48.txt | AC | 40 ms | 2560 KB |
49.txt | AC | 40 ms | 2560 KB |
50.txt | AC | 39 ms | 3328 KB |
51.txt | AC | 39 ms | 2944 KB |
52.txt | AC | 37 ms | 2560 KB |
53.txt | AC | 36 ms | 2560 KB |
54.txt | AC | 37 ms | 2560 KB |