QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#72125 | #5359. 面国建设 | Crysfly | 100 ✓ | 159ms | 9776kb | C++17 | 1.2kb | 2023-01-14 09:34:17 | 2023-01-14 09:34:20 |
Judging History
answer
#include<bits/stdc++.h>
#define For(i,a,b) for(int i=(a);i<=(b);++i)
#define Rep(i,a,b) for(int i=(a);i>=(b);--i)
#define int long long
using namespace std;
inline int read()
{
char c=getchar();int x=0;bool f=0;
for(;!isdigit(c);c=getchar())f^=!(c^45);
for(;isdigit(c);c=getchar())x=(x<<1)+(x<<3)+(c^48);
if(f)x=-x;return x;
}
#define fi first
#define se second
#define pb push_back
#define mkp make_pair
typedef pair<int,int>pii;
typedef vector<int>vi;
#define maxn 400005
#define inf 0x3f3f3f3f3f3f3f3f
int s,c,V;
int f[maxn]; // min C of (2*S-C)
// add (i,j) : S+=i*j C+=i+j 2*S-C+=2*i*j-i-j
int mn[maxn];
void wk(int x){
For(i,0,V)mn[i]=inf;
int t=2*x*x-2*x;
For(i,t,V){
mn[i]=f[i-t]+x*2;
if(i>=(2*x-1))mn[i]=min(mn[i],mn[i-(2*x-1)]+1);
f[i]=min(f[i],mn[i]);
}
}
signed main()
{
s=read(),c=read()/2;
memset(f,63,sizeof f);
f[0]=0; V=2*s;
for(int i=1;i*i<=s;++i)wk(i);
int res=0;
For(i,0,V){
if(f[i]>c)continue;
// cout<<"i: "<<i<<" "<<f[i]<<endl;
int nc=f[i],ns=(f[i]+i)/2;
if(ns>s)continue;
// cout<<nc<<" "<<ns<<endl;
int t=min((c-nc)/2,s-ns)+1;
res+=t;
}
cout<<res-1;
return 0;
}
这程序好像有点Bug,我给组数据试试?
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 6
Accepted
Test #1:
score: 6
Accepted
time: 2ms
memory: 7848kb
input:
4 10
output:
7
result:
ok single line: '7'
Test #2:
score: 0
Accepted
time: 3ms
memory: 7828kb
input:
7 2
output:
0
result:
ok single line: '0'
Test #3:
score: 0
Accepted
time: 3ms
memory: 6644kb
input:
6 6
output:
2
result:
ok single line: '2'
Test #4:
score: 0
Accepted
time: 3ms
memory: 7168kb
input:
10 7
output:
2
result:
ok single line: '2'
Test #5:
score: 0
Accepted
time: 1ms
memory: 7420kb
input:
8 10
output:
8
result:
ok single line: '8'
Test #6:
score: 0
Accepted
time: 3ms
memory: 7252kb
input:
10 8
output:
5
result:
ok single line: '5'
Subtask #2:
score: 12
Accepted
Dependency #1:
100%
Accepted
Test #7:
score: 12
Accepted
time: 2ms
memory: 6676kb
input:
399 994
output:
125266
result:
ok single line: '125266'
Test #8:
score: 0
Accepted
time: 1ms
memory: 8512kb
input:
742 645
output:
184225
result:
ok single line: '184225'
Test #9:
score: 0
Accepted
time: 1ms
memory: 7688kb
input:
932 900
output:
328424
result:
ok single line: '328424'
Test #10:
score: 0
Accepted
time: 2ms
memory: 8576kb
input:
943 971
output:
357500
result:
ok single line: '357500'
Test #11:
score: 0
Accepted
time: 3ms
memory: 7128kb
input:
955 897
output:
335817
result:
ok single line: '335817'
Test #12:
score: 0
Accepted
time: 3ms
memory: 7104kb
input:
903 971
output:
340678
result:
ok single line: '340678'
Test #13:
score: 0
Accepted
time: 0ms
memory: 7832kb
input:
954 978
output:
364964
result:
ok single line: '364964'
Test #14:
score: 0
Accepted
time: 1ms
memory: 6504kb
input:
908 902
output:
319849
result:
ok single line: '319849'
Test #15:
score: 0
Accepted
time: 1ms
memory: 8404kb
input:
934 908
output:
332030
result:
ok single line: '332030'
Test #16:
score: 0
Accepted
time: 1ms
memory: 8132kb
input:
961 924
output:
348391
result:
ok single line: '348391'
Subtask #3:
score: 31
Accepted
Dependency #1:
100%
Accepted
Dependency #2:
100%
Accepted
Test #17:
score: 31
Accepted
time: 0ms
memory: 7700kb
input:
1951 2977
output:
2228950
result:
ok single line: '2228950'
Test #18:
score: 0
Accepted
time: 4ms
memory: 8624kb
input:
4626 5415
output:
10254469
result:
ok single line: '10254469'
Test #19:
score: 0
Accepted
time: 4ms
memory: 7500kb
input:
5983 4766
output:
12197679
result:
ok single line: '12197679'
Test #20:
score: 0
Accepted
time: 4ms
memory: 7380kb
input:
5094 5425
output:
11472637
result:
ok single line: '11472637'
Test #21:
score: 0
Accepted
time: 0ms
memory: 7916kb
input:
5598 4989
output:
11826716
result:
ok single line: '11826716'
Test #22:
score: 0
Accepted
time: 2ms
memory: 6592kb
input:
5577 5188
output:
12208146
result:
ok single line: '12208146'
Test #23:
score: 0
Accepted
time: 4ms
memory: 8100kb
input:
5688 5804
output:
13807758
result:
ok single line: '13807758'
Test #24:
score: 0
Accepted
time: 0ms
memory: 6960kb
input:
5856 5309
output:
13161066
result:
ok single line: '13161066'
Test #25:
score: 0
Accepted
time: 1ms
memory: 8092kb
input:
5378 5859
output:
13061554
result:
ok single line: '13061554'
Test #26:
score: 0
Accepted
time: 4ms
memory: 6912kb
input:
5729 5635
output:
13554877
result:
ok single line: '13554877'
Subtask #4:
score: 51
Accepted
Dependency #1:
100%
Accepted
Dependency #2:
100%
Accepted
Dependency #3:
100%
Accepted
Test #27:
score: 51
Accepted
time: 125ms
memory: 9736kb
input:
177004 361104
output:
23708315017
result:
ok single line: '23708315017'
Test #28:
score: 0
Accepted
time: 116ms
memory: 9600kb
input:
165955 330686
output:
20513788444
result:
ok single line: '20513788444'
Test #29:
score: 0
Accepted
time: 155ms
memory: 9588kb
input:
196341 379690
output:
28146877343
result:
ok single line: '28146877343'
Test #30:
score: 0
Accepted
time: 111ms
memory: 9596kb
input:
157573 352489
output:
19921485073
result:
ok single line: '19921485073'
Test #31:
score: 0
Accepted
time: 126ms
memory: 9664kb
input:
174981 388787
output:
24469285862
result:
ok single line: '24469285862'
Test #32:
score: 0
Accepted
time: 135ms
memory: 9728kb
input:
179053 386583
output:
25166888234
result:
ok single line: '25166888234'
Test #33:
score: 0
Accepted
time: 136ms
memory: 9768kb
input:
181239 344051
output:
23675514126
result:
ok single line: '23675514126'
Test #34:
score: 0
Accepted
time: 152ms
memory: 9600kb
input:
194920 395575
output:
28656790378
result:
ok single line: '28656790378'
Test #35:
score: 0
Accepted
time: 140ms
memory: 9604kb
input:
179011 399658
output:
25686628463
result:
ok single line: '25686628463'
Test #36:
score: 0
Accepted
time: 138ms
memory: 9600kb
input:
183359 394921
output:
26352667541
result:
ok single line: '26352667541'
Test #37:
score: 0
Accepted
time: 159ms
memory: 9540kb
input:
195360 389377
output:
28442072522
result:
ok single line: '28442072522'
Test #38:
score: 0
Accepted
time: 152ms
memory: 9776kb
input:
191706 397710
output:
28122791775
result:
ok single line: '28122791775'
Test #39:
score: 0
Accepted
time: 149ms
memory: 9700kb
input:
191762 396427
output:
28074496102
result:
ok single line: '28074496102'
Test #40:
score: 0
Accepted
time: 150ms
memory: 9732kb
input:
197603 386515
output:
28732769430
result:
ok single line: '28732769430'
Test #41:
score: 0
Accepted
time: 141ms
memory: 9664kb
input:
190189 377777
output:
26893005583
result:
ok single line: '26893005583'
Test #42:
score: 0
Accepted
time: 151ms
memory: 9600kb
input:
189770 391031
output:
27434979251
result:
ok single line: '27434979251'
Test #43:
score: 0
Accepted
time: 156ms
memory: 9660kb
input:
194039 389514
output:
28192735947
result:
ok single line: '28192735947'
Test #44:
score: 0
Accepted
time: 157ms
memory: 9580kb
input:
197815 388430
output:
28870257334
result:
ok single line: '28870257334'
Test #45:
score: 0
Accepted
time: 146ms
memory: 9540kb
input:
189687 383322
output:
27060812973
result:
ok single line: '27060812973'
Test #46:
score: 0
Accepted
time: 155ms
memory: 9600kb
input:
196059 391296
output:
28672072117
result:
ok single line: '28672072117'