比赛日程安排

#pragma comment(linker, "/STACK:102400000,102400000")
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<vector>
#include<algorithm>
#include<iostream>
#include<map>
#include<queue>
#include<stack>
#include<string>
#include<functional>
#include<math.h>
//#include<bits/stdc++.h>
using namespace std;
typedef long long lint;
typedef vector<int> VI;
typedef pair<int, int> PII;
void makedata() {
    freopen("input.txt", "w", stdout);
    cout << 200000 << endl;

    for(int i = 0; i < 200000; i++) cout << 1000000000 << ' ';

    fclose(stdout);
}

const int day[12] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
VI a[100];

int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
#endif
    //makedata();
    //std::ios::sync_with_stdio(0), cin.tie(0);
    int n, m, t;
    scanf("%d", &t);

    while(t--) {
        bool ok = true;
        scanf("%d%d", &n, &m);

        for(int i = 1; i <= n; i++) a[i].clear();

        for(int i = 0; i < m; i++) {
            int mm, d, u, v, tmp = 0;
            scanf("%d-%d%d%d", &mm, &d, &u, &v);

            for(int j = 1; j < mm; j++)tmp += day[j - 1];

            tmp += d;
            a[u].push_back(tmp);
            a[v].push_back(tmp);
        }

        for(int i = 1; i <= n; i++) {
            sort(a[i].begin(), a[i].end());

            for(int j = 1; j < a[i].size(); j++) {
                if(a[i][j] - a[i][j - 1] <= 1) ok = false;
            }
        }

        if(ok) printf("YES\n");
        else printf("NO\n");
    }

    return 0;
}
View Code

相关文章: