QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#253797 | #7629. Make SYSU Great Again II | tuanlinh123 | RE | 0ms | 0kb | C++20 | 1.3kb | 2023-11-17 15:47:50 | 2023-11-17 15:47:50 |
answer
#include<bits/stdc++.h>
#define ll long long
#define pll pair<ll, ll>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define ld long double
using namespace std;
ll gray(ll i)
{
return i^(i>>1);
}
ll a[2005][2005];
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
ll n; cin >> n;
for (ll i=1; i<=n; i++)
for (ll j=1; j<=n; j++)
a[i][j]=-1;
ll b=__lg(n*2), all=(1<<(b*2))-1;
for (ll k=2; k<=n*2; k+=2)
{
ll val=gray(k/2-1);
for (ll i=1; i<=n; i++)
{
ll j=k-i;
if (j<=0 || j>n)
continue;
a[i][j]=val;
}
}
for (ll k=-n+1; k<=n-1; k+=2)
{
ll val=gray((k+n-1)/2)<<b;
for (ll i=1; i<=n; i++)
{
ll j=i-k;
if (j<=0 || j>n)
continue;
a[i][j]|=val;
}
}
cout << "Yes\n";
for (ll i=1; i<=n; i++)
for (ll j=1; j<=n; j++)
{
if (a[i][j]==-1)
a[i][j]=(a[i-1][j]|a[i][j-1]|a[i+1][j]|a[i][j+1])^all;
cout << a[i][j] << " \n"[j==n];
}
}
详细
Test #1:
score: 0
Dangerous Syscalls
input:
4