QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#381438 | #6677. Puzzle: Sashigane | SSHL# | WA | 1ms | 3868kb | C++14 | 1.7kb | 2024-04-07 17:45:50 | 2024-04-07 17:45:51 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
void solve()
{
int n,a,b;
cin>>n>>a>>b;
// cout<<"Yes\n";
vector<int> ans;
int d=min(a-1,n-b);
int r=a-d,w=b+d;
int h=w-r;
bool f=1;
for(;r<=n&&w>=1;r++,w--)
{
if(a==r&&b==w)
{
f=1-f;
h=1;
continue;
}
if(f)
{
ans.push_back(r);
ans.push_back(w);
ans.push_back(h);
ans.push_back(-h);
h--;
}else{
ans.push_back(r);
ans.push_back(w);
ans.push_back(-h);
ans.push_back(h);
h++;
}
}
if(!(r==n+1&&w==0))
{
if(r==n+1)
{
r=a-d-1;
f=1;
}
if(w==0)
{
w=b+d+1;
f=0;
}
h=abs(b-a)+1+2*d;
}
if(f)
{
for(;r>0&&w>0;r--,w--)
{
ans.push_back(r);
ans.push_back(w);
ans.push_back(h);
ans.push_back(h);
h++;
}
}else{
for(;r<=n&&w<=n;r++,w++)
{
ans.push_back(r);
ans.push_back(w);
ans.push_back(-h);
ans.push_back(-h);
h++;
}
}
int p=ans.size()/4;
if(p>((n*n-1)/3))
cout<<"No\n";
else{
cout<<"Yes\n";
cout<<p<<'\n';
for(int i=0;i<(int)ans.size();i+=4)
{
cout<<ans[i]<<' '<<ans[i+1]<<' '<<ans[i+2]<<' '<<ans[i+3]<<'\n';
}
}
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
int t=1;
// cin>>t;
while(t--)
solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3868kb
input:
5 3 4
output:
Yes 4 2 5 3 -3 4 3 -1 1 5 2 -2 2 1 1 4 4
result:
ok Correct. (1 test case)
Test #2:
score: 0
Accepted
time: 1ms
memory: 3556kb
input:
1 1 1
output:
Yes 0
result:
ok Correct. (1 test case)
Test #3:
score: 0
Accepted
time: 0ms
memory: 3528kb
input:
3 2 3
output:
Yes 2 3 2 -1 1 1 1 2 2
result:
ok Correct. (1 test case)
Test #4:
score: -100
Wrong Answer
time: 1ms
memory: 3560kb
input:
10 10 5
output:
Yes 9 5 10 5 -5 6 9 4 -4 7 8 3 -3 8 7 2 -2 9 6 1 -1 4 4 16 16 3 3 17 17 2 2 18 18 1 1 19 19
result:
wrong answer Integer parameter [name=h] equals to 16, violates the range [-10, 10] (test case 1)