69892023-12-23 22:51:02999Egykorúak (75 pont)cpp17Accepted 75/759ms4472 KiB
// Source: https://usaco.guide/general/io

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

struct evszam{
	int ev,ho,nap;
};


vector<int> hok {31,28,31,30,31,30,31,31,30,31,30,31};

int atvalt(evszam a){
	int cnt=0;
	for(int i = 1950;i<a.ev;i++){
		cnt+=365;
		if(i%4==0)cnt++;
	}
	for(int i = 0;i<a.ho;i++){
		cnt+=hok[i];
	}
	if(a.ho>2&&a.ev%4==0)cnt++;
	return cnt+a.nap;
}

signed main(){
	int n;cin>>n;
	evszam peti;
	cin>>peti.ev>>peti.ho>>peti.nap;
	int peeti=atvalt(peti);
	vector<int> vk,vn;
	int ans=0;
	for(int i = 0;i<n;i++){
		evszam a;
		cin>>a.ev>>a.ho>>a.nap;
		if(a.ev==peti.ev+1)vn.push_back(atvalt(a));
		if(a.ev==peti.ev-1)vk.push_back(atvalt(a));
		if(a.ev==peti.ev)ans++;
	}
	for(int p : vk){
		if(p>=peeti-365)ans++;
	}
	for(int p : vn){
		if(p<=peeti+365)ans++;
	}
	cout<<ans<<endl;
}
SubtaskSumTestVerdictTimeMemory
base75/75
1Accepted0/03ms1808 KiB
2Accepted0/09ms2356 KiB
3Accepted5/53ms2316 KiB
4Accepted5/53ms2412 KiB
5Accepted5/53ms2540 KiB
6Accepted5/53ms2788 KiB
7Accepted5/53ms2844 KiB
8Accepted5/53ms2848 KiB
9Accepted5/53ms2852 KiB
10Accepted5/54ms3236 KiB
11Accepted5/54ms3380 KiB
12Accepted5/54ms3732 KiB
13Accepted5/56ms3644 KiB
14Accepted5/56ms3996 KiB
15Accepted5/57ms4024 KiB
16Accepted5/58ms4356 KiB
17Accepted5/58ms4472 KiB