QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#142203#6677. Puzzle: Sashiganexxx2022WA 1ms3824kbC++142.0kb2023-08-18 17:05:172023-08-18 17:05:19

Judging History

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

  • [2023-08-18 17:05:19]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3824kb
  • [2023-08-18 17:05:17]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
inline int read(){
    int x=0,f=1;char c=getchar();
    for(;!isdigit(c);c=getchar())if(c=='-')f=-1;
    for(;isdigit(c);c=getchar())x=(x<<1)+(x<<3)+c-'0';
    return x*f;
}
int n,x,y;
struct node{
    int x,y,h,w;
}ans[1005];
int cnt;
bool check(int a,int b){
    if(a < 1 || a > n || b < 1 || b > n||(a==x&&b==y))return false;
    else return true;
}
inline void dfs(int len,int a1,int b1,int a2,int b2,int a3,int b3,int a4,int b4){
    if(len > n)return;
    if(check(a1,b1)){
        cnt++;
        ans[cnt].x=a1;
        ans[cnt].y=b1;
        if(x > a1)ans[cnt].h = len;
        else ans[cnt].h = -len;
        if(y > b1)ans[cnt].w = len;
        else ans[cnt].w = -len;
        dfs(len+1,a1-1,b1+1,a1+len,b1+1,a1+len,b1-len,a1-1,b1-len);
    }
    else if(check(a2,b2)){
        cnt++;
        ans[cnt].x=a2;
        ans[cnt].y=b2;
        if(x > a2)ans[cnt].h = len;
        else ans[cnt].h = -len;
        if(y > b2)ans[cnt].w = len;
        else ans[cnt].w = -len;
        dfs(len+1,a2-len,b2+1,a2+1,b2+1,a2+1,b2-len,a2-len,b2-len);
    }
    else if(check(a3,b3)){
        cnt++;
        ans[cnt].x=a3;
        ans[cnt].y=b3;
        if(x > a3)ans[cnt].h = len;
        else ans[cnt].h = -len;
        if(y > b3)ans[cnt].w = len;
        else ans[cnt].w = -len;
        dfs(len+1,a3-len,b3+len,a3+1,b3+len,a3+1,b3-1,a3-len,b3-1);
    }
    else if(check(a4,b4)){
        cnt++;
        ans[cnt].x=a4;
        ans[cnt].y=b4;
        if(x > a4)ans[cnt].h = len;
        else ans[cnt].h = -len;
        if(y > b4)ans[cnt].w = len;
        else ans[cnt].w = -len;
        dfs(len+1,a4-1,b4+len,a4+len,b4+len,a4+len,b4-1,a4-1,b4-1);
    }
}
int main(){
    n=read();
    x=read();
    y=read();
    if(n == 1){
        printf("Yes\n0\n");
        return 0;
    }
    printf("Yes\n%d\n",n-1);
    dfs(1,x-1,y+1,x+1,y+1,x+1,y-1,x-1,y-1);
    for(int i=1;i<n;i++){
        cout<<ans[i].x<<' '<<ans[i].y<<' '<<ans[i].h<<' '<<ans[i].w<<endl;
    }
    return 0;
}

详细

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 3824kb

input:

5 3 4

output:

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

result:

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