QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#178883 | #3836. So I'll Max Out My Constructive Algorithm Skills | ballance | WA | 1ms | 3632kb | C++17 | 2.0kb | 2023-09-14 14:53:44 | 2023-09-14 14:53:45 |
Judging History
answer
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <string>
#include <sstream>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<set>
#include<stack>
#include<map>
#include<array>
#include<queue>
#include<cstring>
#include<stdio.h>
#include<cstdlib>
#include<ctime>
#include<cmath>
#include<unordered_map>
#include<random>
#include<bitset>
typedef long long ll;//unsigned
typedef long double ld;
//#define int ll
#define pii pair<int,int>
#define pb push_back
#define fi first
#define se second
using namespace std;
minstd_rand gen;
const ld PI = 3.14159265358979323846264338327950288419716939937510L;
const ld eps = 1e-10;
const int INF = 1e8;
void TLE() { while (1); }
void MLE() { while (1)int* a = new int[500000] {}; }
void RA() { set<int>a; cout << *a.end(); }
void YES() { cout << "YES\n"; }void NO() { cout << "NO\n"; }
const int N = 200010;
//const ll x = 998244353, y = 1000000007;
int a[100][100];
bool bb[100][100];
int dx, dy;
int x, y;
int n;
void turn()
{
int tx = dx, ty = dy;
dx = -ty;
dy = tx;
}
bool check(int x, int y)
{
return 1 <= x && x <= n && 1 <= y && y <= n && !bb[x][y];
}
signed main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int t; cin >> t;
while (t--)
{
cin >> n;
for (int i = 1; i <= n; i++)
for (int j = 1; j <= n; j++)
cin >> a[i][j], bb[i][j] = 0;
x = 1, y = 1;
dx = 1, dy = 0;
vector<int>b;
int c = 0;
int last = 1e9;
while (b.size() < n * n)
{
b.push_back(a[x][y]);
bb[x][y] = 1;
if (!check(x + dx, y + dy))
turn();
x += dx, y += dy;
}
for (int i = 1; i < n * n; i++)
if (b[i] > b[i - 1])
++c;
if (c > n * n / 2)
{
for (int i = n * n - 1; i > 0; i--)
cout << b[i] << ' ';
cout << b[0] << '\n';
}
else
{
for (int i = 0; i < n * n - 1; i++)
cout << b[i] << ' ';
cout << b[n * n - 1] << '\n';
}
}
}
/*
1
3
1 2 3
4 5 6
7 8 9
3
9 8 7
6 5 4
3 2 1
2
4 3
2 1
*/
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3528kb
input:
1 2 4 3 2 1
output:
4 2 1 3
result:
ok correct
Test #2:
score: -100
Wrong Answer
time: 0ms
memory: 3632kb
input:
100 9 30 75 35 51 25 19 76 65 62 11 56 63 60 77 48 28 26 74 16 44 46 41 17 8 66 61 42 29 7 43 38 40 31 27 10 39 52 23 58 80 50 20 33 69 47 79 1 5 49 22 37 71 18 70 54 72 4 64 55 34 12 6 15 14 53 45 13 32 59 73 57 81 36 3 78 24 2 68 9 67 21 7 11 28 2 19 9 41 24 17 34 5 10 42 18 47 33 35 22 8 49 1 29 ...
output:
30 11 16 29 52 79 54 14 36 3 78 24 2 68 9 67 21 81 15 70 47 39 42 74 62 65 76 19 25 51 35 75 56 44 7 23 1 72 53 45 13 32 59 73 57 6 18 69 10 61 26 28 48 77 60 63 46 43 58 5 4 64 55 34 12 71 33 27 66 8 17 41 38 80 49 22 37 20 31 40 50 3 8 49 44 36 25 6 12 22 5 10 42 18 1 7 43 32 48 45 16 27 37 20 35 ...
result:
wrong answer [case 8] Not lazy, up = 32, down = 31