QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#776809#9788. Shrecklessucup-team3670#WA 23ms3752kbC++201.0kb2024-11-23 21:03:012024-11-23 21:03:08

Judging History

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

  • [2024-11-23 21:03:08]
  • 评测
  • 测评结果:WA
  • 用时:23ms
  • 内存:3752kb
  • [2024-11-23 21:03:01]
  • 提交

answer

#include <bits/stdc++.h>

#define forn(i, n) for (int i = 0; i < int(n); ++i)
#define fore(i, l, r) for (int i = int(l); i < int(r); ++i)
#define sz(a) (int)((a).size())

using namespace std;

typedef long long li;

void solve(){
	int n, m;
	cin >> n >> m;
	vector<vector<int>> a(n, vector<int>(m));
	forn(i, n) forn(j, m) cin >> a[i][j];
	vector<multiset<int>> cur(m);
	forn(i, n) forn(j, m) cur[j].insert(a[i][j]);
	vector<pair<int, int>> ord(n * m);
	forn(i, n) forn(j, m) ord[i * m + j] = {i, j};
	sort(ord.begin(), ord.end(), [&](const pair<int, int> &x, const pair<int, int> &y){
		return a[x.first][x.second] > a[y.first][y.second];
	});
	int cnt = 0;
	for (auto [x, y] : ord){
		if (y > 0 && !cur[y - 1].empty() && *cur[y - 1].rbegin() > a[x][y]){
			++cnt;
			cur[y].erase(cur[y].find(a[x][y]));
			cur[y - 1].erase(--cur[y - 1].end());
		}
	}
	cout << (cnt >= n ? "YES" : "NO") << '\n';
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int t;
	cin >> t;
	while (t--) solve();
}

詳細信息

Test #1:

score: 100
Accepted
time: 1ms
memory: 3752kb

input:

3
2 2
69 69
2024 42
3 3
1 1 1
1 1 1
2 2 2
3 4
1 1 1 1
1 1 1 1
2 2 2 2

output:

YES
NO
YES

result:

ok 3 token(s): yes count is 2, no count is 1

Test #2:

score: 0
Accepted
time: 1ms
memory: 3592kb

input:

3
2 2
69 69
2024 42
3 3
1 1 1
1 1 1
2 2 2
3 4
1 1 1 1
1 1 1 1
2 2 2 2

output:

YES
NO
YES

result:

ok 3 token(s): yes count is 2, no count is 1

Test #3:

score: -100
Wrong Answer
time: 23ms
memory: 3612kb

input:

20000
6 2
12 4
8 24
2 10
1 22
3 15
18 20
3 3
3 8 18
2 17 15
13 4 6
3 3
7 17 15
8 6 3
18 13 9
3 3
2 3 14
1 7 17
4 6 13
3 3
6 10 14
3 9 13
1 7 15
2 4
1 3 16 14
6 10 4 2
3 3
3 2 17
7 11 13
16 5 18
2 3
2 3 6
4 1 5
2 4
4 6 13 14
2 11 12 16
3 3
2 8 12
4 9 17
5 7 18
3 2
5 10
8 9
1 6
2 2
2 4
1 3
2 3
12 6 1
...

output:

NO
NO
YES
NO
NO
YES
YES
YES
NO
NO
NO
NO
YES
YES
YES
YES
NO
NO
YES
NO
NO
NO
YES
NO
YES
YES
YES
YES
YES
NO
NO
YES
NO
YES
NO
NO
YES
NO
YES
YES
NO
NO
YES
NO
YES
NO
NO
YES
YES
YES
NO
NO
NO
YES
YES
YES
NO
NO
NO
YES
NO
NO
YES
NO
NO
NO
YES
YES
YES
YES
NO
NO
YES
NO
NO
NO
NO
NO
YES
YES
YES
NO
NO
YES
YES
NO
NO...

result:

wrong answer expected YES, found NO [2nd token]