QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#360045 | #4633. Coprime Matrices | Kevin5307 | WA | 0ms | 3708kb | C++20 | 1.8kb | 2024-03-21 10:41:16 | 2024-03-21 10:41:16 |
Judging History
answer
//Author: Kevin
#include<bits/stdc++.h>
//#pragma GCC optimize("O2")
using namespace std;
#define ll long long
#define ull unsigned ll
#define pb emplace_back
#define mp make_pair
#define ALL(x) (x).begin(),(x).end()
#define rALL(x) (x).rbegin(),(x).rend()
#define srt(x) sort(ALL(x))
#define rev(x) reverse(ALL(x))
#define rsrt(x) sort(rALL(x))
#define sz(x) (int)(x.size())
#define inf 0x3f3f3f3f
#define pii pair<int,int>
#define lb(v,x) (int)(lower_bound(ALL(v),x)-v.begin())
#define ub(v,x) (int)(upper_bound(ALL(v),x)-v.begin())
#define uni(v) v.resize(unique(ALL(v))-v.begin())
#define longer __int128_t
void die(string S){puts(S.c_str());exit(0);}
int ind[303][303],ans[303][303];
int rep[303];
bool used[100100];
int psum[100100];
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int n,m,x,y,w;
cin>>n>>m>>x>>y>>w;
for(int i=2;i<n;i+=2)
{
int tot=0;
for(int j=1;j<=m;j++)
if(j%2)
{
ind[i][j]=++tot;
ind[i+1][j]=++tot;
}
else
{
ind[i+1][j]=++tot;
ind[i][j]=++tot;
}
}
if(!ind[x][y])
{
used[w]=1;
psum[w]=1;
}
else
{
rep[x/2*2]=w-ind[x][y]+1;
for(int i=0;i<m+m;i++)
used[rep[x/2*2]+i]=psum[rep[x/2*2]+i]=1;
}
for(int i=1;i<=n*m;i++)
psum[i]+=psum[i-1];
int p=1;
for(int i=2;i<n;i+=2)
if(!rep[i])
{
while(psum[p+m+m-1]!=psum[p-1])
p++;
rep[i]=p;
p+=m+m;
}
for(int i=2;i<n;i+=2)
for(int j=1;j<=m;j++)
for(int k=0;k<2;k++)
{
ans[i+k][j]=rep[i]+ind[i+k][j]-1;
used[ans[i+k][j]]=1;
}
p=1;
for(int i=1;i<=n;i++)
for(int j=1;j<=m;j++)
if(!ind[i][j])
{
while(used[p]) p++;
used[p]=1;
ans[i][j]=p;
}
for(int i=1;i<=n;i++)
{
for(int j=1;j<=m;j++)
cout<<ans[i][j]<<" ";
cout<<'\n';
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3708kb
input:
3 3 2 1 3
output:
1 2 9 3 6 7 4 5 8
result:
wrong answer First Line not Yes