QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#555103 | #9226. Game of Geniuses | ucup-team2526 | WA | 1ms | 3628kb | C++20 | 2.2kb | 2024-09-09 19:55:54 | 2024-09-09 19:55:55 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define dbg(x...) \
do { \
std::cout << #x << " -> "; \
err(x); \
} while (0)
void err() {
std::cout << std::endl;
}
template<class T, class... Ts>
void err(T arg, Ts &... args) {
std::cout << fixed << setprecision(10) << arg << ' ';
err(args...);
}
int a[55][55],vis[55][55],n;
int find_row() {
vector<int>row[n + 1];
int ans = -1;
for (int i = 1; i <= n; ++i) {
for (int j = 1; j <= n; ++j) {
if (vis[i][j]) continue;
row[i].push_back(a[i][j]);
}
if (!row[i].empty()) {
sort(row[i].begin(),row[i].end());
if (ans == -1) ans = i;
}
}
for (int i = ans + 1; i <= n; ++i) {
int len = row[i].size();
for (int j = 0; j < len; ++j) {
if (row[ans][j] == row[i][j]) continue;
if (row[ans][j] < row[i][j]) break;
else {
ans = i;
break;
}
}
}
return ans;
}
void col_row(int row) {
for (int i = 1; i <= n; ++i) {
vis[row][i] = 1;
}
}
int find_col() {
vector<int>col[n + 1];
int ans = -1;
for (int i = 1; i <= n; ++i) {
for (int j = 1; j <= n; ++j) {
if (vis[j][i]) continue;
col[i].push_back(a[j][i]);
}
if (!col[i].empty()) {
sort(col[i].begin(),col[i].end());
reverse(col[i].begin(),col[i].end());
if (ans == -1) ans = i;
}
}
for (int i = ans + 1; i <= n; ++i) {
int len = col[i].size();
for (int j = 0; j < len; ++j) {
if (col[ans][j] == col[i][j]) continue;
if (col[ans][j] > col[i][j]) break;
else {
ans = i;
break;
}
}
}
return ans;
}
void col_col(int col) {
for (int i = 1; i <= n; ++i) {
vis[i][col] = 1;
}
}
void GENSHEN_START() {
cin >> n;
for (int i = 1; i <= n; ++i) {
for (int j = 1; j <= n; ++j) {
cin >> a[i][j];
}
}
for (int i = 1; i < n; ++i) {
int row = find_row();
col_row(row);
dbg(row);
int col = find_col();
dbg(col);
col_col(col);
}
for (int i = 1; i <= n; ++i) {
for (int j = 1; j <= n; ++j) {
if (!vis[i][j]) cout << a[i][j];
}
}
}
signed main() {
ios::sync_with_stdio(false);cin.tie(nullptr);
int T = 1;
//cin >> T;
while (T--) GENSHEN_START();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 3628kb
input:
3 1 4 9 8 4 2 7 5 7
output:
row -> 1 col -> 1 row -> 2 col -> 3 5
result:
wrong output format Expected integer, but "row" found