QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#555103#9226. Game of Geniusesucup-team2526WA 1ms3628kbC++202.2kb2024-09-09 19:55:542024-09-09 19:55:55

Judging History

你现在查看的是最新测评结果

  • [2024-09-09 19:55:55]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3628kb
  • [2024-09-09 19:55:54]
  • 提交

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;
}

详细

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