This problem looks very scary, but in fact, you will find that it does not have any technical content, do this problem in fact to consider is the earliest end of the day and the beginning of the start of the first time, if the end time is earlier than the start time, then OK on the two, otherwise the output no solution, to note that If you want to separate every day when you pass in, remember to mark the number of each field.
The code is as follows:
#include <cstdlib>#include<cstdio>#include<iostream>using namespacestd;Long Long intI_day,i_huiyi,temp_1,temp_2,temp_3;Long Long inti_hui[ +][500000][3];Long Long inti_nob[ +];Long Long inti_min,nob_1,i_max=80000000, nob_2;intMain () {CIN>>i_huiyi;cin>>I_day; for(intI=0; i<i_huiyi;i++) {cin>>temp_1;cin>>temp_2;cin>>Temp_3; i_hui[temp_3][i_nob[temp_3]][0]=temp_1; i_hui[temp_3][i_nob[temp_3]][1]=temp_2; i_hui[temp_3][i_nob[temp_3]][2]=i+1; I_nob[temp_3]++; } for(intI=1; i<=i_day;i++) { for(intm=0; m<i_nob[i];m++) { if(i_hui[i][m][0]>i_min) {I_min=i_hui[i][m][0]; Nob_1=i_hui[i][m][2]; } if(i_hui[i][m][1]<I_max) {I_max=i_hui[i][m][1]; Nob_2=i_hui[i][m][2]; } } if(i_min>I_max) {cout<<"TAK"<<" "<<nob_1<<" "<<nob_2<<Endl; I_min=0; i_max=80000000; } Else{cout<<"NIE"<<Endl; I_min=0; i_max=80000000; } } return 0;}
Hope my blog can help you, thank you.
Bzoj 4143 the Lawyer