QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#419126 | #6677. Puzzle: Sashigane | bible_w# | WA | 1ms | 3804kb | C++20 | 2.7kb | 2024-05-23 18:02:28 | 2024-05-23 18:02:28 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int dx[] = {1,1,-1,-1};
int dy[] = {-1,1,1,-1};
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n,x,y;
cin >> n >> x >> y;
vector<array<int,4>> ans;
auto check = [&](int x,int y)->bool{
if (x <= n && x >= 1 && y <= n && y >= 1) return true;
return false;
};
int cnt = 1;
vector<pair<int,int>> next;
for (int i = 0;i < 4;i++){
int u = x + dx[i];
int v = y + dy[i];
if (check(u,v)) next.push_back({u,v});
else
next.push_back({-1e9,-1e9});
}
/* for (auto [u,v] : next){
cout << u << " " << v << "\n";
}*/
int cur = 1;
while (cnt != n * n){
int wkx = -1,wky = -1,mxx = -1,mxy = -1,h,w;
for (int i = 0;i < 4;i++){
auto [u,v] = next[i];
if (check(u,v)){
int tmpx = min(abs(u),n - u);
int tmpy = min(v,n - v);
if (tmpx >= mxx && tmpy >= mxy)
mxx = tmpx,mxy = tmpy,wkx = u,wky = v,h = cur * dx[i],w = cur * dy[i];
}
}
/* for (auto [u,v] : next){
cout << u << " " << v << "\n";
}*/
next.clear();
cnt += 2 * cur + 1;
cur++;
cur++;
if (wkx <= x && wky <= y){
ans.push_back({wkx,wky,cur - 2,cur - 2});
wkx--,wky--;
next.push_back({wkx,wky});
next.push_back({wkx + cur,wky});
next.push_back({wkx,wky + cur});
next.push_back({wkx + cur,wky + cur});
}else if (wkx <= x && wky >= y){
ans.push_back({wkx,wky,(cur - 2),-(cur - 2)});
wkx--,wky++;
next.push_back({wkx,wky});
next.push_back({wkx + cur,wky});
next.push_back({wkx + cur,wky + cur});
next.push_back({wkx,wky + cur});
}else if (wkx >= x && wky <= y){
ans.push_back({wkx,wky,-(cur - 2),(cur - 2)});
wkx++,wky--;
next.push_back({wkx,wky});
next.push_back({wkx,wky + cur});
next.push_back({wkx - cur,wky });
next.push_back({wkx - cur,wky + cur});
}else{
ans.push_back({wkx,wky,-(cur - 2),-(cur - 2)});
wkx++,wky++;
next.push_back({wkx,wky});
next.push_back({wkx - cur,wky});
next.push_back({wkx,wky - cur});
next.push_back({wkx - cur,wky - cur});
}
cur--;
}
cout << "Yes\n";
cout << ans.size() << "\n";
for (auto [i,j,k,l] : ans){
cout << i << ' ' << j << ' ' << k << ' ' << l << "\n";
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3640kb
input:
5 3 4
output:
Yes 4 2 3 1 1 4 2 -2 2 1 1 3 3 5 5 -4 -4
result:
ok Correct. (1 test case)
Test #2:
score: 0
Accepted
time: 0ms
memory: 3648kb
input:
1 1 1
output:
Yes 0
result:
ok Correct. (1 test case)
Test #3:
score: 0
Accepted
time: 0ms
memory: 3804kb
input:
3 2 3
output:
Yes 2 1 2 1 1 3 1 -2 2
result:
ok Correct. (1 test case)
Test #4:
score: -100
Wrong Answer
time: 0ms
memory: 3580kb
input:
10 10 5
output:
Yes 9 9 4 1 1 8 6 2 -2 7 7 3 -3 6 8 4 -4 5 9 5 -5 4 10 6 -6 -1 -1 7 7 7 7 8 -8 6 8 9 -9
result:
wrong answer Integer parameter [name=r] equals to -1, violates the range [1, 10] (test case 1)