Submission #2049693


Source Code Expand

Copy
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

bool flag;

bool checkHM(ll H,ll M,ll S){
  ll fa=30*3600*H + 30*(M*60+S);
  ll fb=3600;

  ll sa=60*M*6 + 6*S;
  ll sb=60;

  if(fa*sb==sa*fb)flag=true;
  
  return (fa*sb < sa*fb);
}

bool checkMS(int H,int M,int S){

  if( (60*M*6+6*S) == S*6 *60 )flag=true;
  
  if ( (60*M*6+6*S) < S*6 *60) return true;
  return false;
}

int main(){
  ll H,M,S;
  ll A,B;
  
  cin>>H>>M>>S;
  H%=12;

  ll tmp=0;
  
  cin>>A>>B;

  ll L=1e9;
  ll R=0;
  
  while(1){

    if(A<0 || B<0)break;

    flag=false;
    checkMS(H,M,S);
    checkHM(H,M,S);
    if(A==0 && B==0 && !flag){
      L=min(L,tmp);
      R=max(R,tmp);
    }
    
    int ts=S;
    int tm=M;
    int th=H;
    
    tmp++;
    S++;
    if(S==60){
      S=0;
      M++;
    }
    if(M==60){
      M=0;
      H++;
    }
    if(H==12){
      H=0;
    }

    if( !checkMS(th,tm,ts) )
      A-=checkMS(H,M,S);
    
    if( !checkHM(th,tm,ts) )
      B-=checkHM(H,M,S);
    
    flag=false;
    checkMS(H,M,S);
    checkHM(H,M,S);
    if(A==0 && B==0 && !flag){
      L=min(L,tmp);
      R=max(R,tmp);
    }
    
  }
  if(L<=R)cout<<L<<' '<<R<<endl;
  else cout<<-1<<endl;

  return 0;
}

Submission Info

Submission Time
Task A - アナログ時計
User dohatsutsu
Language C++14 (GCC 5.4.1)
Score 400
Code Size 1297 Byte
Status AC
Exec Time 8 ms
Memory 256 KB

Judge Result

Set Name All
Score / Max Score 400 / 400
Status
AC × 36
Set Name Test Cases
All _sample_01, _sample_02, _sample_03, _sample_04, corner_01, corner_02, fixed-random-01, fixed-random-02, fixed-random-03, fixed-random-04, fixed-random-05, fixed-random-06, fixed-random-07, fixed-random-08, fixed-random-09, fixed-random-10, large-01, large-02, large-03, large-04, large-05, large-06, large-07, large-08, large-09, large-10, random-01, random-02, random-03, random-04, random-05, random-06, random-07, random-08, random-09, random-10
Case Name Status Exec Time Memory
_sample_01 AC 1 ms 256 KB
_sample_02 AC 1 ms 256 KB
_sample_03 AC 1 ms 256 KB
_sample_04 AC 8 ms 256 KB
corner_01 AC 8 ms 256 KB
corner_02 AC 1 ms 256 KB
fixed-random-01 AC 7 ms 256 KB
fixed-random-02 AC 2 ms 256 KB
fixed-random-03 AC 6 ms 256 KB
fixed-random-04 AC 2 ms 256 KB
fixed-random-05 AC 8 ms 256 KB
fixed-random-06 AC 8 ms 256 KB
fixed-random-07 AC 6 ms 256 KB
fixed-random-08 AC 7 ms 256 KB
fixed-random-09 AC 7 ms 256 KB
fixed-random-10 AC 6 ms 256 KB
large-01 AC 8 ms 256 KB
large-02 AC 8 ms 256 KB
large-03 AC 8 ms 256 KB
large-04 AC 8 ms 256 KB
large-05 AC 8 ms 256 KB
large-06 AC 8 ms 256 KB
large-07 AC 8 ms 256 KB
large-08 AC 8 ms 256 KB
large-09 AC 8 ms 256 KB
large-10 AC 8 ms 256 KB
random-01 AC 4 ms 256 KB
random-02 AC 5 ms 256 KB
random-03 AC 2 ms 256 KB
random-04 AC 7 ms 256 KB
random-05 AC 7 ms 256 KB
random-06 AC 3 ms 256 KB
random-07 AC 7 ms 256 KB
random-08 AC 1 ms 256 KB
random-09 AC 3 ms 256 KB
random-10 AC 2 ms 256 KB