QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#784534#9788. Shrecklessorz_zWA 15ms13984kbC++143.6kb2024-11-26 15:16:562024-11-26 15:17:03

Judging History

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

  • [2024-11-26 15:17:03]
  • 评测
  • 测评结果:WA
  • 用时:15ms
  • 内存:13984kb
  • [2024-11-26 15:16:56]
  • 提交

answer

#include <bits/stdc++.h>
#define _rep(i, x, y) for(int i = x; i <= y; ++i)
#define _req(i, x, y) for(int i = x; i >= y; --i)
#define _rev(i, u) for(int i = head[u]; i; i = e[i].nxt)
#define pb push_back
#define fi first
#define se second
#define mst(f, i) memset(f, i, sizeof f)
using namespace std;
#ifdef ONLINE_JUDGE
#define debug(...) 0
#else
#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#endif
typedef long long ll;
typedef pair<int, int> PII;
namespace fastio{
    #ifdef ONLINE_JUDGE
    char ibuf[1 << 20],*p1 = ibuf, *p2 = ibuf;
    #define get() p1 == p2 && (p2 = (p1 = ibuf) + fread(ibuf, 1, 1 << 20, stdin), p1 == p2) ? EOF : *p1++
    #else
    #define get() getchar()
    #endif
    template<typename T> inline void read(T &t){
        T x = 0, f = 1;
        char c = getchar();
        while(!isdigit(c)){
            if(c == '-') f = -f;
            c = getchar();
        }
        while(isdigit(c)) x = x * 10 + c - '0', c = getchar();
        t = x * f;
    }
    template<typename T, typename ... Args> inline void read(T &t, Args&... args){
        read(t);
        read(args...);
    }
    template<typename T> void write(T t){
        if(t < 0) putchar('-'), t = -t;
        if(t >= 10) write(t / 10);
        putchar(t % 10 + '0');
    }
    template<typename T, typename ... Args> void write(T t, Args... args){
        write(t), putchar(' '), write(args...);
    }
    template<typename T> void writeln(T t){
        write(t);
        puts("");
    }
    template<typename T> void writes(T t){
        write(t), putchar(' ');
    }
    #undef get
};
using namespace fastio;
#define multitest() int T; read(T); _rep(tCase, 1, T)
namespace Calculation{
    const ll mod = 998244353;
    ll ksm(ll p, ll h){ll base = p % mod, res = 1; while(h){if(h & 1ll) res = res * base % mod; base = base * base % mod, h >>= 1ll;} return res;}
    void dec(ll &x, ll y){x = ((x - y) % mod + mod) % mod;}
    void add(ll &x, ll y){x = (x + y) % mod;}
    void mul(ll &x, ll y){x = x * y % mod;}
    ll sub(ll x, ll y){return ((x - y) % mod + mod) % mod;}
    ll pls(ll x, ll y){return ((x + y) % mod + mod) % mod;}
    ll mult(ll x, ll y){return x * y % mod;}
}
using namespace Calculation;
const int N = 2e5 + 5;
int n, m, len, lsh[N];
vector<int> a[N], pos[N];

int main(){
    multitest(){
        read(n, m);
        _rep(i, 1, n){
            a[i].resize(m + 2);
            _rep(j, 1, m){
                read(a[i][j]);
                lsh[++len] = a[i][j];
            }
        }
        sort(lsh + 1, lsh + 1 + len), len = unique(lsh + 1, lsh + 1 + len) - lsh - 1;
        _rep(i, 1, n) _rep(j, 1, m) a[i][j] = lower_bound(lsh + 1, lsh + 1 + len, a[i][j]) - lsh;
        _rep(i, 1, n) _rep(j, 1, m) pos[a[i][j]].pb(j);
        multiset<int> st;
        for(auto &i : pos[len]) st.insert(i);
        int ans = 0;
        _req(i, len - 1, 1){
            sort(pos[i].begin(), pos[i].end());
            vector<int> cur;
            for(auto it = prev(pos[i].end()); ; it = prev(it)){
                auto t = st.lower_bound(*it);
                if(t == st.begin()){
                    cur.pb(*it);
                    if(it == pos[i].begin()) break;
                    continue;
                }
                // debug("u:%d v:%d\n", (*prev(t)), (*it));
                st.erase(prev(t)), ans++;
                if(it == pos[i].begin()) break;
            }
            for(auto &j : cur) st.insert(j);
        }
        _rep(i, 1, n) a[i].clear();
        _rep(i, 1, len) pos[i].clear();
        puts(ans >= n ? "YES" : "NO");
        len = 0;
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 3ms
memory: 13984kb

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: 3ms
memory: 12956kb

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

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]