Submission #2203921
Source Code Expand
#include<cstdio> #include<algorithm> #define Mod 1000000007 struct node{ int c,w; }a[100001]; int n,X,Y,mini[100001],min1,min2=Mod,inv[100001],cnt[10001],sum;long long ans=1; bool in1[100001],in2[100001]; bool cmp(node x,node y){return x.w<y.w;} int main() { scanf("%d%d%d",&n,&X,&Y); inv[1]=1;for(int i=2;i<=n;++i)inv[i]=1ll*(Mod-Mod/i)*inv[Mod%i]%Mod; for(int i=2;i<=n;++i)inv[i]=1ll*inv[i-1]*inv[i]%Mod; for(int i=1;i<=n;++i)scanf("%d%d",&a[i].c,&a[i].w); std::sort(a+1,a+n+1,cmp); min1=a[1].w;for(int i=2;i<=n;++i)if(a[i].c!=a[1].c){min2=a[i].w;break;} for(int i=1;i<=n;++i){ if(!mini[a[i].c])mini[a[i].c]=a[i].w,cnt[a[i].c]++,in1[i]=1; else if(a[i].w+mini[a[i].c]<=X&&!in1[i])cnt[a[i].c]++,in1[i]=1; if(a[i].c==a[1].c)if(min2+a[i].w<=Y){ if(!in1[i])cnt[a[i].c]++; in2[a[i].c]=in1[i]=1; } if(a[i].c!=a[1].c)if(min1+a[i].w<=Y){ if(!in1[i])cnt[a[i].c]++; in2[a[i].c]=in1[i]=1; } } for(int i=1;i<=n;++i)if(in2[i]) sum+=cnt[i],ans=1ll*ans*inv[cnt[i]]%Mod; for(int i=2;i<=sum;++i)ans=1ll*ans*i%Mod; printf("%lld\n",ans); return 0; }
Submission Info
Submission Time | |
---|---|
Task | D - Colorful Balls |
User | vjudge3 |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 1074 Byte |
Status | RE |
Exec Time | 126 ms |
Memory | 1664 KB |
Compile Error
./Main.cpp: In function ‘int main()’: ./Main.cpp:12: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:15:52: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] for(int i=1;i<=n;++i)scanf("%d%d",&a[i].c,&a[i].w); ^
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 | 256 KB |
02.txt | AC | 1 ms | 128 KB |
03.txt | AC | 3 ms | 256 KB |
04.txt | AC | 1 ms | 128 KB |
05.txt | AC | 1 ms | 256 KB |
06.txt | AC | 1 ms | 256 KB |
07.txt | RE | 125 ms | 1664 KB |
08.txt | AC | 1 ms | 128 KB |
09.txt | AC | 18 ms | 896 KB |
10.txt | AC | 10 ms | 640 KB |
11.txt | AC | 1 ms | 256 KB |
12.txt | AC | 1 ms | 128 KB |
13.txt | AC | 3 ms | 384 KB |
14.txt | AC | 1 ms | 128 KB |
15.txt | RE | 108 ms | 896 KB |
16.txt | RE | 126 ms | 1664 KB |
17.txt | AC | 5 ms | 384 KB |
18.txt | AC | 13 ms | 768 KB |
19.txt | AC | 26 ms | 1408 KB |
20.txt | RE | 118 ms | 1664 KB |
21.txt | RE | 119 ms | 1664 KB |
22.txt | RE | 117 ms | 1664 KB |
23.txt | RE | 116 ms | 1664 KB |
24.txt | RE | 118 ms | 1664 KB |
25.txt | RE | 119 ms | 1664 KB |
26.txt | RE | 118 ms | 1664 KB |
27.txt | RE | 119 ms | 1664 KB |
28.txt | RE | 119 ms | 1664 KB |
29.txt | RE | 119 ms | 1664 KB |
30.txt | RE | 120 ms | 1664 KB |
31.txt | RE | 119 ms | 1664 KB |
32.txt | RE | 120 ms | 1664 KB |
33.txt | RE | 119 ms | 1664 KB |
34.txt | RE | 116 ms | 1664 KB |
35.txt | RE | 118 ms | 1664 KB |
36.txt | RE | 117 ms | 1664 KB |
37.txt | RE | 119 ms | 1664 KB |
38.txt | RE | 118 ms | 1664 KB |
39.txt | RE | 118 ms | 1664 KB |
40.txt | RE | 116 ms | 1664 KB |
41.txt | RE | 117 ms | 1664 KB |
42.txt | RE | 116 ms | 1664 KB |
43.txt | RE | 116 ms | 1664 KB |
44.txt | RE | 118 ms | 1664 KB |
45.txt | RE | 117 ms | 1664 KB |
46.txt | RE | 116 ms | 1664 KB |
47.txt | RE | 117 ms | 1664 KB |
48.txt | RE | 118 ms | 1664 KB |
49.txt | RE | 117 ms | 1664 KB |
50.txt | RE | 115 ms | 1664 KB |
51.txt | RE | 115 ms | 1664 KB |
52.txt | RE | 115 ms | 1664 KB |
53.txt | RE | 115 ms | 1664 KB |
54.txt | RE | 117 ms | 1664 KB |