QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#419087#6677. Puzzle: Sashiganebible_w#WA 1ms3680kbC++202.7kb2024-05-23 17:42:302024-05-23 17:42:34

Judging History

你现在查看的是最新测评结果

  • [2024-05-23 17:42:34]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3680kb
  • [2024-05-23 17:42:30]
  • 提交

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: 3640kb

input:

1 1 1

output:

Yes
0

result:

ok Correct. (1 test case)

Test #3:

score: 0
Accepted
time: 0ms
memory: 3664kb

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: 3680kb

input:

10 10 5

output:

Yes
9
9 4 1 1
8 6 2 -2
3 7 3 -3
2 8 4 -4
1 9 5 -5
-1 -1 6 6
6 6 7 -7
5 7 8 -8
4 8 9 -9

result:

wrong answer Integer parameter [name=r] equals to -1, violates the range [1, 10] (test case 1)