QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#773862#9788. Shrecklessucup-team4474#WA 17ms4036kbC++202.3kb2024-11-23 10:36:552024-11-23 10:36:56

Judging History

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

  • [2024-11-23 10:36:56]
  • 评测
  • 测评结果:WA
  • 用时:17ms
  • 内存:4036kb
  • [2024-11-23 10:36:55]
  • 提交

answer

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

bool Memory_begin;

const int N = 3e5 + 5;
int s[N];
int lowbit(int x) { return x & -x; }
void add(int x, int y)
{
    while (x < N)
    {
        s[x] += y;
        x += lowbit(x);
    }
}
int query(int x)
{
    int res = 0;
    while (x)
    {
        res += s[x];
        x -= lowbit(x);
    }
    return res;
}

bool Memory_end;

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    cerr << (&Memory_end - &Memory_begin) / 1048576.0 << "MB" << '\n';

    int t;
    cin >> t;
    while (t--)
    {
        int n, m;
        cin >> n >> m;
        vector a(n, vector<int>(m));
        for (int i = 0; i < n; i++)
            for (int j = 0; j < m; j++)
                cin >> a[i][j];
        vector<int> ok(n);
        {
            vector<int> tmp;
            for (int i = 0; i < n; i++)
                tmp.push_back(a[i][0]);
            sort(tmp.begin(), tmp.end());
            for (int i = 0; i < n; i++)
                a[i][0] = tmp[n - i - 1];
        }
        for (int j = 1; j < m; j++)
        {
            multiset<int> tmp;
            for (int i = 0; i < n; i++)
                tmp.insert(a[i][j]), a[i][j] = 0;
            for (int i = 0; i < n; i++)
            {
                if (ok[i])
                    continue;
                auto it = tmp.lower_bound(a[i][j - 1]);
                if (it == tmp.begin())
                {
                    for (int x = i; x < n; x++)
                    {
                        a[x][j] = *tmp.rbegin();
                        tmp.erase(tmp.find(a[x][j]));
                    }
                    break;
                }
                ok[i] = 1;
                it = prev(it);
                a[i][j] = *it;
                tmp.erase(it);
            }
            if (!tmp.empty())
            {
                for (int i = 0; i < n; i++)
                {
                    if (a[i][j])
                        continue;
                    a[i][j] = *tmp.rbegin();
                    tmp.erase(tmp.find(a[i][j]));
                }
            }
            assert(tmp.empty());
        }
        if (ok.back())
            cout << "YES\n";
        else
            cout << "NO\n";
    }
}
/*

*/

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 4036kb

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: 0ms
memory: 3828kb

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: 17ms
memory: 3760kb

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]