Submission #1809723
Source Code Expand
#include<cstdio> #include<cstring> #include<algorithm> #include<cstdlib> #include<ctime> #include<utility> using namespace std; typedef long long ll; typedef unsigned long long ull; typedef pair<int,int> pii; ll p=1000000007; ll f[200010]; ll g[200010]; ll a[200010]; ll A,B; ll sf[200010]; ll sg[200010]; int la[200010]; int lb[200010]; int main() { #ifdef DEBUG freopen("a.in","r",stdin); freopen("a.out","w",stdout); #endif int n; scanf("%d%lld%lld",&n,&A,&B); int i; for(i=1;i<=n;i++) scanf("%lld",&a[i]); a[0]=-3000000000000000000; a[n+1]=3000000000000000000; int j1=0,j2=0; f[0]=g[0]=sf[0]=sg[0]=1; la[0]=lb[0]=0; for(i=1;i<=n;i++) { while(j1<=i-2&&a[j1+1]<=a[i+1]-B) j1++; while(j2<=i-2&&a[j2+1]<=a[i+1]-A) j2++; if(a[i]-a[i-1]>=A) la[i]=la[i-1]; else la[i]=i; if(a[i]-a[i-1]>=B) lb[i]=lb[i-1]; else lb[i]=i; if(j1>=la[i]-1) { f[i]=sg[j1]; if(la[i]-1>=1) f[i]-=sg[la[i]-2]; } if(j2>=lb[i]-1) { g[i]=sf[j2]; if(lb[i]-1>=1) g[i]-=sf[lb[i]-2]; } f[i]%=p; g[i]%=p; sf[i]=(sf[i-1]+f[i])%p; sg[i]=(sg[i-1]+g[i])%p; } ll ans=f[n]+g[n]; ans=(ans%p+p)%p; printf("%lld\n",ans); return 0; }
Submission Info
Submission Time | |
---|---|
Task | D - Colorful Balls |
User | yww |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 1246 Byte |
Status | WA |
Exec Time | 34 ms |
Memory | 9472 KB |
Compile Error
./Main.cpp: In function ‘int main()’: ./Main.cpp:27:30: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] scanf("%d%lld%lld",&n,&A,&B); ^ ./Main.cpp:30:22: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] scanf("%lld",&a[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 | WA | 2 ms | 6272 KB |
00_example_02.txt | WA | 2 ms | 6272 KB |
00_example_03.txt | WA | 2 ms | 6272 KB |
01.txt | WA | 2 ms | 6272 KB |
02.txt | WA | 2 ms | 6272 KB |
03.txt | WA | 3 ms | 6400 KB |
04.txt | WA | 2 ms | 6272 KB |
05.txt | WA | 2 ms | 6400 KB |
06.txt | WA | 2 ms | 6272 KB |
07.txt | WA | 17 ms | 7936 KB |
08.txt | WA | 2 ms | 6272 KB |
09.txt | WA | 10 ms | 7424 KB |
10.txt | WA | 7 ms | 6912 KB |
11.txt | WA | 2 ms | 6272 KB |
12.txt | WA | 2 ms | 6272 KB |
13.txt | WA | 3 ms | 6400 KB |
14.txt | WA | 2 ms | 6272 KB |
15.txt | WA | 8 ms | 6912 KB |
16.txt | WA | 17 ms | 7936 KB |
17.txt | WA | 4 ms | 6528 KB |
18.txt | WA | 9 ms | 7040 KB |
19.txt | WA | 16 ms | 7808 KB |
20.txt | WA | 33 ms | 9472 KB |
21.txt | WA | 33 ms | 9472 KB |
22.txt | WA | 33 ms | 9472 KB |
23.txt | WA | 33 ms | 9472 KB |
24.txt | WA | 33 ms | 9472 KB |
25.txt | WA | 33 ms | 9472 KB |
26.txt | WA | 33 ms | 9472 KB |
27.txt | WA | 33 ms | 9472 KB |
28.txt | WA | 33 ms | 9472 KB |
29.txt | WA | 33 ms | 9472 KB |
30.txt | WA | 33 ms | 9472 KB |
31.txt | WA | 33 ms | 9472 KB |
32.txt | WA | 33 ms | 9472 KB |
33.txt | WA | 33 ms | 9472 KB |
34.txt | WA | 32 ms | 9472 KB |
35.txt | WA | 34 ms | 9472 KB |
36.txt | WA | 33 ms | 9472 KB |
37.txt | WA | 34 ms | 9472 KB |
38.txt | WA | 34 ms | 9472 KB |
39.txt | WA | 33 ms | 9472 KB |
40.txt | WA | 32 ms | 9472 KB |
41.txt | WA | 32 ms | 9472 KB |
42.txt | WA | 32 ms | 9472 KB |
43.txt | WA | 32 ms | 9472 KB |
44.txt | WA | 32 ms | 9472 KB |
45.txt | WA | 32 ms | 9472 KB |
46.txt | WA | 32 ms | 9472 KB |
47.txt | WA | 32 ms | 9472 KB |
48.txt | WA | 33 ms | 9472 KB |
49.txt | WA | 32 ms | 9472 KB |
50.txt | WA | 29 ms | 9472 KB |
51.txt | WA | 29 ms | 9472 KB |
52.txt | WA | 29 ms | 9472 KB |
53.txt | WA | 29 ms | 9472 KB |
54.txt | WA | 29 ms | 9472 KB |