QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#611711 | #9134. Building a Fence | WarrnaCute | WA | 2ms | 3588kb | C++14 | 1.6kb | 2024-10-04 22:15:53 | 2024-10-04 22:15:55 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int inf=1e18;
int solve(int a,int b,int c)
{
if(a==0&&b==0) return 0;
if(a==0) return 1+(b+b!=c);
if(b==0) return 1+(a+a!=c);
int less=c-a;
if(b<less) return 4;
if(b==less) return 2;
if(b<less+less) return 4;
if(b==less+less) return 3;
if(b==(c-b)+less+less) return 3;
return 4;
}
int solve2(int a,int b,int c)
{
int less=c-b;
if(less+less==a) return 3;
return inf;
}
int solve3(int a,int b,int c)
{
int less=c-b+c-b+c-a%c;
if(less==a) return 3;
return inf;
}
int solve4(int a,int b,int c)
{
int less=c-b;
if(less+less>=a||a-less-less>=c) return inf;
int lesss=a-less-less;
if(a-lesss<0) return inf;
if(a-lesss==0) return 3;
return 4;
}
int solve5(int a,int b,int c)
{
int less=c-b;
if(less+less>=a||a-less-less>=c) return inf;
int lesss=a-less-less;
if(a-c-lesss>c) return inf;
return 4;
}
void solve()
{
int x,y,c,ans=0;
cin>>x>>y>>c;
int a=x%c,b=y%c;
ans=2*(x/c+y/c)+min(solve(a,b,c),solve(b,a,c));
if(a+c<=x) ans=min(ans,2*(x/c+y/c)-1+solve2(a+c,b,c));
if(b+c<=y) ans=min(ans,2*(x/c+y/c)-1+solve2(b+c,a,c));
if(a+2*c<=x) ans=min(ans,2*(x/c+y/c)-2+solve3(a+2*c,b,c));
if(b+2*c<=y) ans=min(ans,2*(x/c+y/c)-2+solve3(b+2*c,a,c));
if(a+c<=x) ans=min(ans,2*(x/c+y/c)-2+solve4(a+c,b,c));
if(b+c<=y) ans=min(ans,2*(x/c+y/c)-2+solve4(a+c,b,c));
if(a+2*c<=x) ans=min(ans,2*(x/c+y/c)-3+solve5(a+2*c,b,c));
if(b+2*c<=y) ans=min(ans,2*(x/c+y/c)-3+solve5(b+2*c,a,c));
cout<<ans<<"\n";
}
signed main()
{
ios::sync_with_stdio(0);
cin.tie(0);cout.tie(0);
int t;
cin>>t;
while(t--) solve();
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 3560kb
input:
7 7 9 4 1 1 2 1 1 4 4 6 2 3 3 5 10 6 4 1 11 5
output:
8 2 4 10 4 8 5
result:
ok 7 numbers
Test #2:
score: -100
Wrong Answer
time: 2ms
memory: 3588kb
input:
8000 1 1 1 1 1 2 1 1 3 1 1 4 1 1 5 1 1 6 1 1 7 1 1 8 1 1 9 1 1 10 1 1 11 1 1 12 1 1 13 1 1 14 1 1 15 1 1 16 1 1 17 1 1 18 1 1 19 1 1 20 1 2 1 1 2 2 1 2 3 1 2 4 1 2 5 1 2 6 1 2 7 1 2 8 1 2 9 1 2 10 1 2 11 1 2 12 1 2 13 1 2 14 1 2 15 1 2 16 1 2 17 1 2 18 1 2 19 1 2 20 1 3 1 1 3 2 1 3 3 1 3 4 1 3 5 1 3...
output:
4 2 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 6 3 2 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 8 4 4 2 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 10 5 4 4 2 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 12 6 4 6 4 2 4 4 4 4 4 4 4 4 4 4 4 4 4 4 14 7 5 4 6 4 2 4 4 4 4 4 4 4 4 4 4 4 4 4 16 8 6 4 6 6 4 2 4 4 4 4 4 4 4 4 4 4 4 4 18 9 6 5 4 6 6 4...
result:
wrong answer 24th numbers differ - expected: '3', found: '4'