QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#543499#6677. Puzzle: Sashiganezzz111WA 0ms3612kbC++203.6kb2024-09-01 17:01:152024-09-01 17:01:15

Judging History

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

  • [2024-09-01 17:01:15]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3612kb
  • [2024-09-01 17:01:15]
  • 提交

answer

#include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define pii pair<int, int>
#define fr(i, a, b) for (int(i) = (a); (i) <= (b); (i)++)
#define br(i, a, b) for (int(i) = (a); (i) >= (b); (i)--)
#define PI acos(-1)
using namespace std;

const int maxn = 1e3 + 3;
int a[maxn][maxn];

inline void solve()
{
    int n, x, y;
    cin >> n >> x >> y;
    cout << "Yes" << endl;
    int nn = n;
    int xx = 1, yy = 1;
    int sum = 0;
    vector<int> r, c, h, w;
    while(nn >= 2)
    {
        //cout << xx << " " << yy << "**" << endl;
        //cout << sum << "%%%" << endl;
        //cout << nn << "&&" << endl;
        if(x <= xx + nn / 2 - 1 && y <= yy + nn / 2 - 1)//左上
        {
            int t = min(yy + nn - 1 - y, xx + nn - 1 - x);
            sum += t;
            nn = nn - t;
            fr(i, xx + nn, xx + nn + t - 1)
            {
                r.push_back(i);
            }
            fr(i, yy + nn, yy + nn + t - 1)
            {
                c.push_back(i);
            }
            fr(i, nn, nn + t - 1)
            {
                h.push_back(-i);
                w.push_back(-i);
            }
            continue;
        }
       // cout << "$$$$$$$$$$$" << endl;
        if (x >= xx + nn / 2 - 1 && y <= yy + nn / 2 - 1)//左下
        {
            int t = min(yy + nn - 1 - y, x - 1);
            sum += t;
            xx = xx + t;
            nn = nn - t;
            br(i, xx - 1, xx - t)
            {
                r.push_back(i);
            }
            fr(i, yy + nn, yy + nn + t - 1)
            {
                c.push_back(i);
            }
            fr(i, nn, nn + t - 1)
            {
                h.push_back(i);
                w.push_back(-i);
            }
            continue;
        }
        //cout <<x<< " "<<y <<" "<< "#######" << endl;
        if (x > xx + nn / 2 - 1 && y > yy + nn / 2 - 1)//右下
        {
            //cout <<xx<<" "<<yy<< "==========================" << endl;
            int t = min(y - 1, x - 1) ;
            sum += t;
            xx = xx + t;
            yy = yy + t;
            nn = nn - t;
            br(i, xx - 1, xx - t)
            {
                r.push_back(i);
            }
            br(i, yy - 1, yy - t)
            {
                c.push_back(i);
            }
            fr(i, nn, nn + t - 1)
            {
                h.push_back(i);
                w.push_back(i);
            }
            continue;
        }
        //cout << x << " " << xx + nn / 2 - 1 << " " << y << " " << yy + nn / 2 - 1 << endl;
        if (x <= xx + nn / 2 - 1 && y >= yy + nn / 2 - 1)
        {
            //cout << "**" << endl;
            int t = min(y - 1, xx + nn - 1 - x);
            sum += t;
            yy = yy + t;
            nn = nn - t;
            fr(i, xx + nn, xx + nn + t - 1)
            {
                r.push_back(i);
            }
            br(i, yy - 1, yy - t)
            {
                c.push_back(i);
            }
            fr(i, nn, nn + t - 1)
            {
                h.push_back(-i);
                w.push_back(i);
            }
            continue;
        }
    }
    cout << sum << endl;
    //cout << r.size() - 1 << " " << c.size() << "**" << endl;
    
    fr(i, 0, (int)r.size() - 1)
    {
        //cout << i << "&&" << endl;
        //cout << "*" << endl;
        cout << r[i] << " " << c[i] << " " << h[i] << " " << w[i] << endl;
    }
}

signed main()
{
/*     ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0); */
    int T;
    T = 1;
    while (T--)
    {
        solve();
    }
}

詳細信息

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3612kb

input:

5 3 4

output:

Yes
4
2 2 3 3
1 1 4 4
4 4 -1 1
5 3 -2 2

result:

wrong answer position (3,4) covered twice. (test case 1)