QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#796617#9788. ShrecklessInspiring Misery (Chen Luoxin)#WA 15ms3608kbC++20948b2024-12-01 22:15:252024-12-01 22:15:25

Judging History

This is the latest submission verdict.

  • [2024-12-01 22:15:25]
  • Judged
  • Verdict: WA
  • Time: 15ms
  • Memory: 3608kb
  • [2024-12-01 22:15:25]
  • Submitted

answer

#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;

void solve() {
    int n, m; cin >> n >> m;
    vector<vector<int>> cols(m, vector<int>(n));
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            cin >> cols[j][i];
        }
    }
    swap(n, m);
    for (int i = 0; i < n; i++) ranges::sort(cols[i]);
    vector<vector<int>> vis(n, vector<int>(m));
    int cnt = 0;
    for (int i = n - 1; i >= 1; i--) {
        int pnt = 0;
        for (int j = 0; j < m; j++) {
            if (vis[i][j]) continue;
            while (pnt < m && (vis[i - 1][pnt] || cols[i - 1][pnt] <= cols[i][j])) pnt++;
            if (pnt < m) {
                cnt++; vis[i - 1][pnt] = 1; pnt++;
            }
        }
    }
    cout << (cnt >= m ? "YES" : "NO") << "\n";
}

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

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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: 3568kb

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: 15ms
memory: 3608kb

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
YES
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
N...

result:

wrong answer expected YES, found NO [610th token]