QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#624901#7752. The Only Way to the DestinationSatonWA 0ms3556kbC++201.6kb2024-10-09 16:51:322024-10-09 16:51:32

Judging History

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

  • [2024-10-09 16:51:32]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3556kb
  • [2024-10-09 16:51:32]
  • 提交

answer

///by Saton.
#include<bits/stdc++.h>
#define PI acos(-1)
#define fi first
#define se second 
#define sz(a) ((int)a.size())
#define all(a) a.begin(), a.end()
#define int long long
#define rep(i,a,b) for(int i = (a);i <= (b);i ++)
#define lep(i,a,b) for(int i = (a);i >= (b);i --)
#define FLUSH fflush(stdout)
using namespace std;
typedef pair<int,int> PII;
int n,m,k;

bool solve() {
    cin >> n >> m >> k;
    const int N = 2*k+1;
    vector<vector<PII>> w(N+1);
    rep(i,1,k) {
        int x1,x2,y;
        cin >> x1 >> x2 >> y;
        if(y<=N) w[i].push_back({x1,x2});
    }
    
    if(n==1) return true;
    if(m>k) return false;
    
    int edge = 0,node = 0;
    vector<PII> lst,cur;
    rep(i,1,m) {
        sort(all(w[i]));
        cur.clear();
        int l = 1;
        for(auto [x1,x2] : w[i]) {
            cur.push_back({l,x1-1});
            l = x2+1;
        }
        if(l<=n) cur.push_back({l,n});
        node += sz(cur);
        
        auto it = lst.begin();
        for(auto [curl,curr] : cur) {
            while(it!=lst.end() && it->fi<=curr) {
                auto [lstl,lstr] = *it ++;
                int l = max(curl,lstl),r = min(curr,lstr);
                if(l==r) edge ++;
                if(l<r) return false; 
            }
            if(it!=lst.end()) {
                it --;
            }
        }
        
        lst = cur;
    }
    
    return (node == edge-1);
} 

signed main() {
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    if(solve()) cout << "YES";
    else cout << "NO";
}  
/*   /\_/\
*   (= ._.)
*   / >  \>
*/

詳細信息

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3556kb

input:

5 3 2
2 5 1
1 4 3

output:

NO

result:

wrong answer expected YES, found NO