QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#345511 | #7740. Puzzle: Question Mark | Sorting# | WA | 154ms | 6836kb | C++20 | 2.5kb | 2024-03-07 02:56:02 | 2024-03-07 02:56:03 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e5+5;
const int ts=262144;
int n,m,o;
int a[2005][2005];
int r[2][4]={{1,1,2,2},{1,2,1,2}};
void fill24(int x,int y){
for(int i=0; i<2 ;i++){
for(int j=0; j<4 ;j++){
a[x+i+o][y+j+o]=m+r[i][j];
}
}
m+=2;
}
void fill42(int x,int y){
for(int i=0; i<4 ;i++){
for(int j=0; j<2 ;j++){
a[x+i+o][y+j+o]=m+r[j][i];
}
}
m+=2;
}
int frog[4][5]={
{1,1,3,3,4},
{1,2,3,4,3},
{0,1,2,4,4},
{0,2,2,0,0},
};
int toad[3][3]={
{1,2,1},
{2,1,1},
{2,2,0}
};
void bang(int n){
if(n<=2) return;
if(n==5){
a[n-2+o][n-1+o]=a[n-2+o][n+o]=a[n-1+o][n+o]=a[n+o][n-1+o]=m+1;
a[n-1+o][n-2+o]=a[n-1+o][n-1+o]=a[n+o][n-2+o]=a[n+o][n+o]=m+2;
m+=2;
fill24(1,2);
a[3+o][1+o]=a[4+o][2+o]=a[5+o][1+o]=a[5+o][2+o]=m+1;
++m;
return;
}
if(n%4==0){
for(int i=1; i<=n ;i+=2){
for(int j=1; j<=n ;j+=4){
fill24(i,j);
}
}
return;
}
if(n%4==2){
for(int i=1; i<=n-4 ;i+=4){
fill24(n-1,i);
fill42(i,n-1);
}
bang(n-2);
return;
}
if(n%4==3){
for(int i=1; i<=n-4 ;i+=4){
fill24(n-1,i);
fill42(i,n-1);
}
a[n-2+o][n-1+o]=a[n-2+o][n+o]=a[n-1+o][n+o]=a[n+o][n-1+o]=m+1;
a[n-1+o][n-2+o]=a[n-1+o][n-1+o]=a[n+o][n-2+o]=a[n+o][n+o]=m+2;
m+=2;
bang(n-2);
return;
}
if(n%4==1){
for(int i=1; i<=n-5 ;i+=4){
fill24(1,i);
}
for(int i=6; i<=n ;i+=4){
fill24(n-1,i);
}
for(int i=3; i<=n-4 ;i+=4){
fill42(i,1);
}
for(int i=4; i<=n-3 ;i+=4){
fill42(i,n-1);
}
for(int i=0; i<4 ;i++){
for(int j=0; j<5 ;j++){
if(frog[i][j]==0) continue;
a[i+1+o][n-4+j+o]=frog[i][j]+m;
a[n-i+o][5-j+o]=frog[i][j]+m+4;
}
}
m+=8;
for(int i=6; i<=n-4 ;i+=4){
fill24(3,i);
fill42(i,3);
}
for(int i=5; i<=n-5 ;i+=4){
fill24(n-3,i);
fill42(i,n-3);
}
for(int i=0; i<3 ;i++){
for(int j=0; j<3 ;j++){
if(toad[i][j]==0) continue;
a[i+3+o][j+3+o]=toad[i][j]+m;
a[n-2-i+o][n-2-j+o]=toad[i][j]+m+2;
}
}
m+=4;
o+=4;
bang(n-8);
return;
}
}
void solve(){
cin >> n;m=0;o=0;
for(int i=1; i<=n ;i++){
for(int j=1; j<=n ;j++){
a[i][j]=0;
}
}
bang(n);
cout << m << '\n';
for(int i=1; i<=n ;i++){
for(int j=1; j<=n ;j++){
//if(a[i][j]==0) cout << "0";
cout << a[i][j] << ' ';
}
cout << '\n';
}
}
int main(){
ios::sync_with_stdio(false);cin.tie(0);
int t;cin >> t;while(t--) solve();
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3644kb
input:
2 3 4
output:
2 0 1 1 2 2 1 2 1 2 4 1 1 2 2 1 2 1 2 3 3 4 4 3 4 3 4
result:
ok Correct. (2 test cases)
Test #2:
score: -100
Wrong Answer
time: 154ms
memory: 6836kb
input:
246 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 ...
output:
0 0 0 0 0 0 0 2 0 1 1 2 2 1 2 1 2 4 1 1 2 2 1 2 1 2 3 3 4 4 3 4 3 4 5 0 3 3 4 4 0 3 4 3 4 5 0 0 1 1 0 5 2 2 1 5 5 2 1 2 8 5 5 6 6 3 3 5 6 5 6 3 4 7 7 8 8 4 3 7 8 7 8 4 4 1 1 2 2 0 0 1 2 1 2 0 0 11 0 9 9 10 10 3 3 0 9 10 9 10 3 4 11 0 0 7 7 4 3 0 11 8 8 7 4 4 11 11 8 7 8 5 5 ...
result:
wrong answer Jury has better answer. Participant 41, jury 42 (test case 13)