QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#434299#4633. Coprime MatricesxlwangWA 0ms3784kbC++142.1kb2024-06-08 15:32:212024-06-08 15:32:22

Judging History

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

  • [2024-06-08 15:32:22]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3784kb
  • [2024-06-08 15:32:21]
  • 提交

answer

#include<bits/stdc++.h>
#define ll long long
#define fr(i,j,k) for(register int i=j;i<=k;++i)
#define rf(i,j,k) for(register int i=j;i>=k;--i)
#define foredge(i,j) for(register int i=head[j];i;i=e[i].nxt)
#define pb push_back
#define Times printf("Time:%.3lf\n",clock()/CLOCKS_PER_SEC)
#define pii pair<int,int>
#define mk make_pair
using namespace std;
inline int read(){
	int x=0;
	bool f=0;
	char c=getchar();
	while(!isdigit(c)) f|=(c=='-'),c=getchar();
	while(isdigit(c)) x=(x<<3)+(x<<1)+(c^48),c=getchar();
	return f?-x:x;
}
inline void write(int x){
    if(x<0){putchar('-');x=-x;}
    if(x>9)write(x/10);
    putchar(x%10+'0');
}
inline void writeln(int x){write(x); puts("");}
inline void writepl(int x){write(x); putchar(' ');}
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
inline int randfind(int l,int r){return rnd()%(r-l+1)+l;}
//inline void init(){
//	int t=read();
//	while(t--) work();
//}
const int Maxn=3e2+10;
int n,m,x,y,w;
int num[Maxn][Maxn];
inline void init(){
    n=read();m=read();x=read();y=read();w=read();
}
inline bool check(int x,int y){return x>=1 && x<=n && y>=1 && y<=m;}
int dx[]={0,1,0,1};
int dy[]={1,0,-1,0};
inline void work(){
    int nod=0;
    for(int i=1;i+1<=m;i+=2){
        int idx=1,idy=i,id=0;
        while(check(idx,idy)){
            // cerr<<idx<<' '<<idy<<endl;
            num[idx][idy]=++nod;
            idx+=dx[id];idy+=dy[id];
            ++id;if(id==4) id=0;
        }
    }
    fr(i,1,n) fr(j,1,m) if(!num[i][j]) num[i][j]=++nod;
    // fr(i,1,n){
    //     fr(j,1,m) cout<<num[i][j]<<' ';
    //     cout<<endl;
    // }
    int k;
    if(num[x][y]<=w) k=w-num[x][y];
    else k=n*m-(num[x][y]-w);
    // cout<<k<<endl;
    fr(i,1,n) fr(j,1,m){
        num[i][j]+=k;
        while(num[i][j]>n*m) num[i][j]-=n*m;
    }
    puts("Yes");
    fr(i,1,n){
        fr(j,1,m) writepl(num[i][j]);
        puts("");
    }
}
signed main(){
	// freopen("input.in","r",stdin);
	// freopen("output.out","w",stdout);
    init();work();
    // printf("\nTIME:%.3lf",(double)clock()/CLOCKS_PER_SEC);
	return 0;
}

详细

Test #1:

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

input:

3 3 2 1 3

output:

Yes
9 1 6 
3 2 7 
4 5 8 

result:

wrong output format Expected EOLN