QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#593498#4633. Coprime Matricesucup-team3161#WA 1ms6316kbC++143.0kb2024-09-27 14:23:382024-09-27 14:23:38

Judging History

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

  • [2024-09-27 14:23:38]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:6316kb
  • [2024-09-27 14:23:38]
  • 提交

answer

#include <bits/stdc++.h>
#define For(i,a,b) for(int i=(a);i<=(b);++i)
#define Rep(i,a,b) for(int i=(a);i>=(b);--i)
using namespace std;

int n,m,x,y,w;
int id[305][305],aa[305][305];
int P(int i,int j){
    return (i-1)*m+j;
}
typedef vector<int>vi;
#define pb push_back
vi e[100005];
bool vis[100005];
void add(int u,int v){
    e[u].pb(v),e[v].pb(u);
}
bool rev;

int tot;
void dfs(int u){
    if(vis[u])return; vis[u]=1;
  //  cout<<"dfs "<<" "<<(u-1)/m+1<<" "<<(u-1)%m+1<<" "<<tot<<"\n";
    id[(u-1)/m+1][(u-1)%m+1]=++tot;
    for(int v:e[u]) dfs(v);
}
signed main()
{
	cin>>n>>m>>x>>y>>w;
    puts("Yes");

    if(n%2==0 && m%2!=0){
        swap(n,m);
        rev=1;
    }

    For(i,1,n){
        For(j,1,m){
            if((i+j)%2==0){
                if(i+1<=n) add(P(i,j),P(i+1,j));
                if(j+1<=m) add(P(i,j),P(i,j+1));
            }
        }
    }
    For(i,1,n){
        For(j,1,m){
            if(e[P(i,j)].size()<=1){
             //   cout<<"GO "<<i<<" "<<j<<"\n";
                dfs(P(i,j));
            }
        }
    }
/*
    bool ad=0;
    if(n%2==1 && m%2==1) ad=1,--m;
    bool op=0;
    if(m%2==0){
        for(int i=1;i<=m;i+=2){
            op^=1;
            if(n&1){
                if(op==1){
                    For(j,1,n) {
                        if(j&1)id[j][i]=++tot,id[j][i+1]=++tot;
                        else id[j][i+1]=++tot,id[j][i]=++tot;
                    }
                }else{
                    Rep(j,n,1){
                        if(j&1)id[j][i]=++tot,id[j][i+1]=++tot;
                        else id[j][i+1]=++tot,id[j][i]=++tot;
                    }
                }
            }else{
                if(op==1){
                    For(j,1,n-2){
                        if(j&1)id[j][i]=++tot,id[j][i+1]=++tot;
                        else id[j][i+1]=++tot,id[j][i]=++tot;
                    }
                    id[n-1][i]=++tot;
                    id[n][i]=++tot;
                    id[n][i+1]=++tot;
                    id[n-1][i+1]=++tot;
                }else{
                    id[n-1][i]=++tot;
                    id[n][i]=++tot;
                    id[n][i+1]=++tot;
                    id[n-1][i+1]=++tot;
                    Rep(j,n-2,1){
                        if(j&1)id[j][i]=++tot,id[j][i+1]=++tot;
                        else id[j][i+1]=++tot,id[j][i]=++tot;
                    }
                }
            }
        }
    }
    if(ad){
        ++m;
        op^=1;
        if(op==1){
            For(j,1,n) id[j][m]=++tot;
        }else{
            Rep(j,n,1) id[j][m]=++tot;
        }
    }

    if(rev){
        For(i,1,n)For(j,1,m)aa[j][i]=id[i][j];
        swap(n,m);
        For(i,1,n)For(j,1,m)id[i][j]=aa[i][j];
    }
*/
    int add=(w-id[x][y]);
   // add=0;
    For(i,1,n){
        For(j,1,m){
            id[i][j]+=add;
            while(id[i][j]<=0)id[i][j]+=n*m;
            while(id[i][j]>n*m)id[i][j]-=n*m;
            cout<<id[i][j]<<" \n"[j==m];
        }
    }
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 6316kb

input:

3 3 2 1 3

output:

Yes
2 1 4
3 6 5
8 7 9

result:

ok OK, Accepted.

Test #2:

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

input:

1 1 1 1 1

output:

Yes
1

result:

ok OK, Accepted.

Test #3:

score: -100
Wrong Answer
time: 0ms
memory: 5904kb

input:

8 3 4 2 9

output:

Yes
11 10 14 13 20 19 2 1
12 16 15 22 21 4 3 7
18 17 24 23 6 5 9 8

result:

wrong output format Expected EOLN