QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#837607#9788. ShrecklesscharlyjoeRE 0ms0kbC++201.5kb2024-12-30 09:36:522024-12-30 09:36:52

Judging History

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

  • [2024-12-30 09:36:52]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:0kb
  • [2024-12-30 09:36:52]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
using ii = pair<int,int>;
using vii = vector<ii>;
using vi = vector<ll>;
ll gcd(ll a, ll b) {return a == 0? b: gcd(b%a,a);}
ll lcm(ll a, ll b) {return a * (b / gcd(a,b));}
#define pb push_back
#define FOR(i,a,b)  for(int i = (a); i < (b); i++)
#define all(x) (x).begin(), (x).end()
#define endl '\n'
#define lb(v,a) lower_bound(v.begin(),v.end(),a)-v.begin()
#define ub(v,a) upper_bound(v.begin(),v.end(),a)-v.begin()-1
    

    int main(){
        ios::sync_with_stdio(0);
        cin.tie(0);
        int x; cin >> x;
        while(x--){
            ll n,m; cin >> n >> m;
            vector<vi> adj(n, vi(m));
            FOR(i,0,n){
                FOR(j,0,m){
                    cin >> adj[i][j];
                }
            }
            ll ans = 0;
            multiset<ll> s;
            FOR(i,0,m){
                multiset<ll> aux;
                FOR(j,0,n){
                    aux.insert(adj[j][i]);
                }
                for(auto x : aux){
                    if(s.upper_bound(x) != s.end()){
                        s.erase(s.upper_bound(x));
                        ans++;
                        aux.erase(aux.find(x));
                    }
                }
                for(auto x : aux) s.insert(x);
            }
            if(ans == n) cout << "YES" << endl;
            else cout << "NO" << endl;
        }
    }

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Runtime Error

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:


result: