Search is not available for this dataset
name
stringlengths
2
112
description
stringlengths
29
13k
source
int64
1
7
difficulty
int64
0
25
solution
stringlengths
7
983k
language
stringclasses
4 values
1493_B. Planet Lapituletti
The time on the planet Lapituletti goes the same way it goes on Earth but a day lasts h hours and each hour lasts m minutes. The inhabitants of that planet use digital clocks similar to earth ones. Clocks display time in a format HH:MM (the number of hours in decimal is displayed first, then (after the colon) follows t...
2
8
C = [0, 1, 2, 5, 8] times_possible = [] for a1 in C: for a2 in C: for a3 in C: for a4 in C: times_possible.append(((a1*10 + a2), (a3*10 + a4))) def reflect(x): f = x / 10 s = x % 10 if f == 5: f = 2 elif f == 2: f = 5 if s == 5: s = 2 elif s == 2: s = 5 return s * ...
PYTHON
1493_B. Planet Lapituletti
The time on the planet Lapituletti goes the same way it goes on Earth but a day lasts h hours and each hour lasts m minutes. The inhabitants of that planet use digital clocks similar to earth ones. Clocks display time in a format HH:MM (the number of hours in decimal is displayed first, then (after the colon) follows t...
2
8
#include <bits/stdc++.h> #define FOR(ii,aa,bb) for(int ii=aa;ii<bb;ii++) #define for0(ii,bb) FOR(ii,0,bb) #define for1(ii,bb) FOR(ii,1,bb+1) #define pb push_back #define mp make_pair #define st first #define nd second #define pii pair<int,int> #define piii pair<pii,int> #define sp " " #define nl "\n" #define all(x) x.b...
CPP
1493_B. Planet Lapituletti
The time on the planet Lapituletti goes the same way it goes on Earth but a day lasts h hours and each hour lasts m minutes. The inhabitants of that planet use digital clocks similar to earth ones. Clocks display time in a format HH:MM (the number of hours in decimal is displayed first, then (after the colon) follows t...
2
8
#include <bits/stdc++.h> using namespace std; #define mp make_pair #define pb push_back typedef long long ll; ll f[10 + 7] = {0, 1, 5, INT_MAX, INT_MAX, 2, INT_MAX, INT_MAX, 8, INT_MAX}; void solve(){ int h, m, H, M, g, s, before; scanf("%d %d", &h, &m); scanf("%d:%d", &H, &M); before = H; do{ ...
CPP
1493_B. Planet Lapituletti
The time on the planet Lapituletti goes the same way it goes on Earth but a day lasts h hours and each hour lasts m minutes. The inhabitants of that planet use digital clocks similar to earth ones. Clocks display time in a format HH:MM (the number of hours in decimal is displayed first, then (after the colon) follows t...
2
8
# 1493/problem/B def replaceNthCh(str,n,ch): if n>=len(str): return str return str[0:n]+ch+str[n+1:len(str)] def isValidHours(num): if num<hoursPerDay: return True else: return False def isValidMinutes(num): if num<minutesPerHour: return True else: return...
PYTHON3
1493_B. Planet Lapituletti
The time on the planet Lapituletti goes the same way it goes on Earth but a day lasts h hours and each hour lasts m minutes. The inhabitants of that planet use digital clocks similar to earth ones. Clocks display time in a format HH:MM (the number of hours in decimal is displayed first, then (after the colon) follows t...
2
8
#include "bits/stdc++.h" using namespace std; using ll = long long; using pii = pair <int, int>; using pll = pair <ll, ll>; #define FIO() ios_base::sync_with_stdio(0);cin.tie(NULL); string orig = "0123456789"; string nw = "015xx2xx8x"; map <char, char> mp; int main() { FIO(); for (int i = 0; i < 10; i++) ...
CPP
1493_B. Planet Lapituletti
The time on the planet Lapituletti goes the same way it goes on Earth but a day lasts h hours and each hour lasts m minutes. The inhabitants of that planet use digital clocks similar to earth ones. Clocks display time in a format HH:MM (the number of hours in decimal is displayed first, then (after the colon) follows t...
2
8
ref = [0, 1, 5, -1, -1, 2, -1, -1, 8, -1] def solve(h, m, time): h0 = int(time[:2]) m0 = int(time[3:]) a = [h0//10, h0%10, m0//10, m0%10] b = list(map(lambda x: ref[x], a))[::-1] while True: h1 = 10*b[0]+b[1] m1 = 10*b[2]+b[3] if -1 not in b and h1 < h and m1 < m: ...
PYTHON3
1493_B. Planet Lapituletti
The time on the planet Lapituletti goes the same way it goes on Earth but a day lasts h hours and each hour lasts m minutes. The inhabitants of that planet use digital clocks similar to earth ones. Clocks display time in a format HH:MM (the number of hours in decimal is displayed first, then (after the colon) follows t...
2
8
import math d = {0: 0, 1: 1, 2: 5, 5: 2, 8: 8} def standardize(s, h, m): if s[1] == m: s[1] = 0 s[0] += 1 if s[0] == h: s[0] = 0 s[1] = 0 return s def get_next_time(s, h, m): # print(s) s = standardize(s, h, m) s[1] += 1 # print(s) return standardiz...
PYTHON3
1493_B. Planet Lapituletti
The time on the planet Lapituletti goes the same way it goes on Earth but a day lasts h hours and each hour lasts m minutes. The inhabitants of that planet use digital clocks similar to earth ones. Clocks display time in a format HH:MM (the number of hours in decimal is displayed first, then (after the colon) follows t...
2
8
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; #define int ll int h, m; int inv(int x) { if (x == 0) return 0; if (x == 1) return 1; if (x == 2) return 5; if (x == 3) return -1; if (x == 4) return -1; if (x == 5) return 2; if (x == 6) return -1; if (x == ...
CPP
1493_B. Planet Lapituletti
The time on the planet Lapituletti goes the same way it goes on Earth but a day lasts h hours and each hour lasts m minutes. The inhabitants of that planet use digital clocks similar to earth ones. Clocks display time in a format HH:MM (the number of hours in decimal is displayed first, then (after the colon) follows t...
2
8
import java.util.*; import java.lang.*; import java.io.*; public class First { // *** ++ // +=-==+ +++=- // +-:---==+ *+=----= // +-:------==+ ...
JAVA
1493_B. Planet Lapituletti
The time on the planet Lapituletti goes the same way it goes on Earth but a day lasts h hours and each hour lasts m minutes. The inhabitants of that planet use digital clocks similar to earth ones. Clocks display time in a format HH:MM (the number of hours in decimal is displayed first, then (after the colon) follows t...
2
8
#include<bits/stdc++.h> using namespace std; int main(){ int t; cin>>t; while(t--){ int h,m; cin>>h>>m; string s; cin>>s; int hh, mm; hh = (s[0]-'0')*10+(s[1]-'0'); mm = (s[3]-'0')*10+(s[4]-'0'); int a,b; bool flag=fal...
CPP
1493_B. Planet Lapituletti
The time on the planet Lapituletti goes the same way it goes on Earth but a day lasts h hours and each hour lasts m minutes. The inhabitants of that planet use digital clocks similar to earth ones. Clocks display time in a format HH:MM (the number of hours in decimal is displayed first, then (after the colon) follows t...
2
8
#include<bits/stdc++.h> #include<iostream> #include<cstdio> #include<algorithm> #include<cmath> #include<cstring> #include<stack> using namespace std; inline bool read(int &num) { char in;bool IsN=false;in=getchar(); if(in==EOF) return false; while(in!='-'&&(in<'0'||in>'9')) in=getchar(); if(in=='-'){ ...
CPP
1493_B. Planet Lapituletti
The time on the planet Lapituletti goes the same way it goes on Earth but a day lasts h hours and each hour lasts m minutes. The inhabitants of that planet use digital clocks similar to earth ones. Clocks display time in a format HH:MM (the number of hours in decimal is displayed first, then (after the colon) follows t...
2
8
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.StringTokenizer; public class B { static class FastScanner { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new St...
JAVA
1493_B. Planet Lapituletti
The time on the planet Lapituletti goes the same way it goes on Earth but a day lasts h hours and each hour lasts m minutes. The inhabitants of that planet use digital clocks similar to earth ones. Clocks display time in a format HH:MM (the number of hours in decimal is displayed first, then (after the colon) follows t...
2
8
import java.io.*; import java.util.*; public class Asd { static List<Integer> good = Arrays.asList(new Integer[] {0, 1, 2, 5, 8}); static int conv[] = new int[]{0, 1, 5, 0, 0, 2,0, 0, 8, 0}; public static void main(String[] args) throws NumberFormatException, IOException { BufferedReader br = new BufferedR...
JAVA
1493_B. Planet Lapituletti
The time on the planet Lapituletti goes the same way it goes on Earth but a day lasts h hours and each hour lasts m minutes. The inhabitants of that planet use digital clocks similar to earth ones. Clocks display time in a format HH:MM (the number of hours in decimal is displayed first, then (after the colon) follows t...
2
8
ref = {0:'0', 1:'1', 2:'5', 5:'2', 8:'8'} def turn(x): #input int, return str d_1,d_10 = map(lambda x: ref.get(x,''),[x//10,x%10]) if d_1 and d_10: ret = d_10 + d_1 else: ret = None return ret N = int(input()) for case in range(N): H,M = map(int,input().split()) h,m = map(int,...
PYTHON3
1493_B. Planet Lapituletti
The time on the planet Lapituletti goes the same way it goes on Earth but a day lasts h hours and each hour lasts m minutes. The inhabitants of that planet use digital clocks similar to earth ones. Clocks display time in a format HH:MM (the number of hours in decimal is displayed first, then (after the colon) follows t...
2
8
import java.io.*; import java.lang.*; import java.util.*; public class B1493 { public static void main(String[] args) throws IOException{ StringBuffer ans = new StringBuffer(); StringTokenizer st; BufferedReader f = new BufferedReader(new InputStreamReader(System.in)); st = new Str...
JAVA
1493_B. Planet Lapituletti
The time on the planet Lapituletti goes the same way it goes on Earth but a day lasts h hours and each hour lasts m minutes. The inhabitants of that planet use digital clocks similar to earth ones. Clocks display time in a format HH:MM (the number of hours in decimal is displayed first, then (after the colon) follows t...
2
8
l=[0,1,2,5,8] le=len(l) for _ in range(int(input())): a,b=map(int,input().split()) s=input() hh="" mm="" hh+=s[:2] mm+=s[3:] hh=int(hh) mm=int(mm) f=0 temp=[0]*5 arr=[0]*5 idx=1 ht=hh while(ht>=1): arr[idx]=ht%10 ht//=10 idx-=1 ht=mm ...
PYTHON3
1493_B. Planet Lapituletti
The time on the planet Lapituletti goes the same way it goes on Earth but a day lasts h hours and each hour lasts m minutes. The inhabitants of that planet use digital clocks similar to earth ones. Clocks display time in a format HH:MM (the number of hours in decimal is displayed first, then (after the colon) follows t...
2
8
import sys import bisect input_=lambda: sys.stdin.readline().strip("\r\n") from math import log ip=lambda :input_() ii=lambda:int(input_()) sc=lambda:input_().split() il=lambda:list(map(int,input_().split())) d={'0':'0','1':'1','2':'5','5':'2','8':'8'} valid=['0','1','2','5','8'] def val(a): h1,h2,m1,m2=str(a[0]%1...
PYTHON3
1493_B. Planet Lapituletti
The time on the planet Lapituletti goes the same way it goes on Earth but a day lasts h hours and each hour lasts m minutes. The inhabitants of that planet use digital clocks similar to earth ones. Clocks display time in a format HH:MM (the number of hours in decimal is displayed first, then (after the colon) follows t...
2
8
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; public class B { public static boolean isValid(int[] arr,int h,int m){ int[] newTime = new int[4]; for(int i=0;i<4;i++){ if(arr[3-i] == 1){ ne...
JAVA
1493_B. Planet Lapituletti
The time on the planet Lapituletti goes the same way it goes on Earth but a day lasts h hours and each hour lasts m minutes. The inhabitants of that planet use digital clocks similar to earth ones. Clocks display time in a format HH:MM (the number of hours in decimal is displayed first, then (after the colon) follows t...
2
8
import math import sys from collections import * import itertools def cint() : return list(map(int, sys.stdin.readline().strip().split())) def cstr() : return list(map(str, input().split(' '))) def solve(t): maxhour, maxmin = cstr() s = input() s = s.replace(':','') h1,h2,m1,m2 = [i for i in s...
PYTHON3
1493_B. Planet Lapituletti
The time on the planet Lapituletti goes the same way it goes on Earth but a day lasts h hours and each hour lasts m minutes. The inhabitants of that planet use digital clocks similar to earth ones. Clocks display time in a format HH:MM (the number of hours in decimal is displayed first, then (after the colon) follows t...
2
8
import java.util.*; public class Solution{ public static void main (String[] args){ Scanner in = new Scanner(System.in); int t = in.nextInt(); for(int T = 0; T < t; T++){ int h = in.nextInt(); //possible hours in a day int m = in.nextInt(); //possible mins in a day int lenh = (h + "").leng...
JAVA
1493_B. Planet Lapituletti
The time on the planet Lapituletti goes the same way it goes on Earth but a day lasts h hours and each hour lasts m minutes. The inhabitants of that planet use digital clocks similar to earth ones. Clocks display time in a format HH:MM (the number of hours in decimal is displayed first, then (after the colon) follows t...
2
8
arr=[-1 for i in range(0,10)] arr[0]=0 arr[1]=1 arr[2]=5 arr[5]=2 arr[8]=8 def check(a,b,h,m): if arr[a%10]==-1 or arr[a//10]==-1 or arr[b%10]==-1 or arr[b//10]==-1: return 0 else: x=arr[b%10]*10+arr[b//10] y=arr[a%10]*10+arr[a//10] if x<h and y<m: return ...
PYTHON3
1493_B. Planet Lapituletti
The time on the planet Lapituletti goes the same way it goes on Earth but a day lasts h hours and each hour lasts m minutes. The inhabitants of that planet use digital clocks similar to earth ones. Clocks display time in a format HH:MM (the number of hours in decimal is displayed first, then (after the colon) follows t...
2
8
import java.util.*; import java.lang.*; import java.io.*; public class CF { public static void main(String[] args) { new B().run(); } static class B{ Scanner in; Map<Integer, Integer> map = new HashMap<Integer, Integer>(); public void run() { in = new Scanner(System.in); int t = in.nextInt(); Str...
JAVA
1493_B. Planet Lapituletti
The time on the planet Lapituletti goes the same way it goes on Earth but a day lasts h hours and each hour lasts m minutes. The inhabitants of that planet use digital clocks similar to earth ones. Clocks display time in a format HH:MM (the number of hours in decimal is displayed first, then (after the colon) follows t...
2
8
import java.util.*; import java.io.*; public class Rextester { static final FS sc = new FS(); static final PrintWriter pw = new PrintWriter(System.out); static final Util u = new Util(); static Set<Integer> invalid = new HashSet<>(); static int[] map = new int[9]; public s...
JAVA
1493_B. Planet Lapituletti
The time on the planet Lapituletti goes the same way it goes on Earth but a day lasts h hours and each hour lasts m minutes. The inhabitants of that planet use digital clocks similar to earth ones. Clocks display time in a format HH:MM (the number of hours in decimal is displayed first, then (after the colon) follows t...
2
8
#include <bits/stdc++.h> using namespace std; #define ll long long #define dbg puts("It's Just Begining.Wait For The End!!!!!\n") #define CHECK(x) cout << (#x) << " is " << (x) <<"\n"; #define endl printf("\n") #define pi acos(-1) typedef pair<ll,ll> pii; #define pb push_back #define ms(a,b) memset(a, b, sizeof(a)) #de...
CPP
1493_B. Planet Lapituletti
The time on the planet Lapituletti goes the same way it goes on Earth but a day lasts h hours and each hour lasts m minutes. The inhabitants of that planet use digital clocks similar to earth ones. Clocks display time in a format HH:MM (the number of hours in decimal is displayed first, then (after the colon) follows t...
2
8
#include<bits/stdc++.h> using namespace std; typedef long long ll; inline ll rd(){ char c=getchar();ll s=0;bool f=1; for(;c<'0'||c>'9';c=getchar())if(c=='-')f=0; for(;c>='0'&&c<='9';c=getchar())s=(s<<3)+(s<<1)+(c^48); return f?s:~(s-1); } inline void wt1(ll x){if(x>=10)wt1(x/10);putchar('0'+x%10);} inline void w...
CPP
1493_B. Planet Lapituletti
The time on the planet Lapituletti goes the same way it goes on Earth but a day lasts h hours and each hour lasts m minutes. The inhabitants of that planet use digital clocks similar to earth ones. Clocks display time in a format HH:MM (the number of hours in decimal is displayed first, then (after the colon) follows t...
2
8
#include<bits/stdc++.h> using namespace std; typedef long long ll; int mod = 1e9+7; #define vi vector<int> #define pb push_back #define ff first #define ss second #define pi pair<int,int> #define all(v) (v).begin(),(v).end() #define mk(arr,n,type) type *arr=new type[n]; #define rrep(i, n) for(int i=n-1;i>=0;i--) #def...
CPP
1493_B. Planet Lapituletti
The time on the planet Lapituletti goes the same way it goes on Earth but a day lasts h hours and each hour lasts m minutes. The inhabitants of that planet use digital clocks similar to earth ones. Clocks display time in a format HH:MM (the number of hours in decimal is displayed first, then (after the colon) follows t...
2
8
import java.util.*; import java.io.*; public class A2oj2 { static FastReader sc; static PrintWriter out; static int mod = 1000000007; public static void main(String[] args) throws IOException { if (System.getProperty("ONLINE_JUDGE") == null) { File f1 = new File("input.txt"); ...
JAVA
1493_B. Planet Lapituletti
The time on the planet Lapituletti goes the same way it goes on Earth but a day lasts h hours and each hour lasts m minutes. The inhabitants of that planet use digital clocks similar to earth ones. Clocks display time in a format HH:MM (the number of hours in decimal is displayed first, then (after the colon) follows t...
2
8
#include <bits/stdc++.h> using namespace std; #define mod (int)1e9+7 #define MOD 998244353 #define ll long long #define mp make_pair #define deb(x) cout<< x << endl #define F first #define S second #def...
CPP
1493_B. Planet Lapituletti
The time on the planet Lapituletti goes the same way it goes on Earth but a day lasts h hours and each hour lasts m minutes. The inhabitants of that planet use digital clocks similar to earth ones. Clocks display time in a format HH:MM (the number of hours in decimal is displayed first, then (after the colon) follows t...
2
8
#include<bits/stdc++.h> #define FOR(i,a,b) for(int i=(a),i##z=(b);i<=i##z;i++) #define temT template<typename T> #define temT12 template<typename T1,typename T2> #define fi first #define se second using namespace std; typedef pair<int,int> pii; temT void clearDS(T &x){ T y; swap(x,y); } int T,H,M; int a[4],b[4]; voi...
CPP
1493_B. Planet Lapituletti
The time on the planet Lapituletti goes the same way it goes on Earth but a day lasts h hours and each hour lasts m minutes. The inhabitants of that planet use digital clocks similar to earth ones. Clocks display time in a format HH:MM (the number of hours in decimal is displayed first, then (after the colon) follows t...
2
8
import java.io.*; import java.util.*; /* polyakoff */ public class Main { static FastReader in; static PrintWriter out; static Random rand = new Random(); static final int oo = (int) 1e9 + 10; static final long OO = (long) 2e18 + 10; static final int MOD = (int) 1e9 + 7; static final int ...
JAVA
1493_B. Planet Lapituletti
The time on the planet Lapituletti goes the same way it goes on Earth but a day lasts h hours and each hour lasts m minutes. The inhabitants of that planet use digital clocks similar to earth ones. Clocks display time in a format HH:MM (the number of hours in decimal is displayed first, then (after the colon) follows t...
2
8
#include <bits/stdc++.h> using namespace std; int main() { #ifndef ONLINE_JUDGE freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif int t; cin >> t; while (t--) { int h, m; cin >> h >> m; string time; cin >> time; ...
CPP
1493_B. Planet Lapituletti
The time on the planet Lapituletti goes the same way it goes on Earth but a day lasts h hours and each hour lasts m minutes. The inhabitants of that planet use digital clocks similar to earth ones. Clocks display time in a format HH:MM (the number of hours in decimal is displayed first, then (after the colon) follows t...
2
8
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import static java.lang.Math.*; import static java.lang.System.out; import java.util.*; import java.io.PrintStream; import java.io.PrintWriter; public class Main { /* 10^(7) = 1s. * ceilVal = (a+b-1) / b */ static fin...
JAVA
1493_B. Planet Lapituletti
The time on the planet Lapituletti goes the same way it goes on Earth but a day lasts h hours and each hour lasts m minutes. The inhabitants of that planet use digital clocks similar to earth ones. Clocks display time in a format HH:MM (the number of hours in decimal is displayed first, then (after the colon) follows t...
2
8
#include <bits/stdc++.h> #define int long long using namespace std; int t, h, m; char trash; int refdigit(int d) { if (d == 0) return 0; if (d == 1) return 1; if (d == 2) return 5; if (d == 3) return -1; if (d == 4) return -1; if (d == 5) return 2; if (d == 6) return -1; if (d == 7) r...
CPP
1493_B. Planet Lapituletti
The time on the planet Lapituletti goes the same way it goes on Earth but a day lasts h hours and each hour lasts m minutes. The inhabitants of that planet use digital clocks similar to earth ones. Clocks display time in a format HH:MM (the number of hours in decimal is displayed first, then (after the colon) follows t...
2
8
for _ in range(int(input())): h,m = map(int,input().split()) x,y = map(int,input().split(":")) s = ["0","1","5","-1","-1","2","-1","-1","8","-1"] i,j = x,y f = 0 while(i<=h-1): f = 0 while(j<=m-1): q,w = str(i),str(j) if(len(q)==1): q = "0"...
PYTHON3
1493_B. Planet Lapituletti
The time on the planet Lapituletti goes the same way it goes on Earth but a day lasts h hours and each hour lasts m minutes. The inhabitants of that planet use digital clocks similar to earth ones. Clocks display time in a format HH:MM (the number of hours in decimal is displayed first, then (after the colon) follows t...
2
8
N=100 a=0,1,5,N,N,2,N,N,8,N def f(i):i+=x*m+y;return f'{i//m%h:02}:{i%m:02}' def g(s):u,v,x,y=(a[int(x)]for x in s if':'>x);return h>x+y*10and v*10+u<m R=lambda x=' ':map(int,input().split(x)) t,=R() while t:t-=1;h,m=R();x,y=R(':');print(next(filter(g,map(f,range(h*m)))))
PYTHON3
1493_B. Planet Lapituletti
The time on the planet Lapituletti goes the same way it goes on Earth but a day lasts h hours and each hour lasts m minutes. The inhabitants of that planet use digital clocks similar to earth ones. Clocks display time in a format HH:MM (the number of hours in decimal is displayed first, then (after the colon) follows t...
2
8
import math,sys from collections import defaultdict,deque import bisect as bi def yes():print('YES') def no():print('NO') def I():return (int(sys.stdin.readline())) def In():return(map(int,sys.stdin.readline().split())) def Sn():return sys.stdin.readline().strip() def Pr(x): sys.stdout.write(str(x)+'\n') #sys.setrecurs...
PYTHON3
1493_B. Planet Lapituletti
The time on the planet Lapituletti goes the same way it goes on Earth but a day lasts h hours and each hour lasts m minutes. The inhabitants of that planet use digital clocks similar to earth ones. Clocks display time in a format HH:MM (the number of hours in decimal is displayed first, then (after the colon) follows t...
2
8
import sys import os handler = open('input') if 'HOME' in os.environ else sys.stdin T = int(handler.readline()) def repeat(func): for _ in range(T): func() @repeat def solve(): h, m = map(int, handler.readline().split()) a, b = map(int, handler.readline().strip().split(':')) d = {'0': '0', '1': '1', '...
PYTHON3
1493_B. Planet Lapituletti
The time on the planet Lapituletti goes the same way it goes on Earth but a day lasts h hours and each hour lasts m minutes. The inhabitants of that planet use digital clocks similar to earth ones. Clocks display time in a format HH:MM (the number of hours in decimal is displayed first, then (after the colon) follows t...
2
8
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; typedef vector<vector<int>> graph; #define pii pair <ll, ll> //#define int ll #define double long double #define all(x) x.begin(), x.end() #define rall(x) x.rbegin(), x.rend() #define PI acos(-1.0) #define F first #de...
CPP
1493_B. Planet Lapituletti
The time on the planet Lapituletti goes the same way it goes on Earth but a day lasts h hours and each hour lasts m minutes. The inhabitants of that planet use digital clocks similar to earth ones. Clocks display time in a format HH:MM (the number of hours in decimal is displayed first, then (after the colon) follows t...
2
8
import java.util.*; public class Main { public static void main(String[] args){ Scanner sc = new Scanner(System.in); int[] vd = {1,1,1,0,0,1,0,0,1,0}; int t = sc.nextInt(); for ( int zzz=0; zzz<t; zzz++ ) { int h = sc.nextInt(); int m = sc.nextInt(); String s = sc.next(); int hh = Integer.valu...
JAVA
1493_B. Planet Lapituletti
The time on the planet Lapituletti goes the same way it goes on Earth but a day lasts h hours and each hour lasts m minutes. The inhabitants of that planet use digital clocks similar to earth ones. Clocks display time in a format HH:MM (the number of hours in decimal is displayed first, then (after the colon) follows t...
2
8
t=int(input()) k = [0, 1, 5, -1, -1, 2, -1, -1, 8, -1] for z in range(t): h, m = map(int, input().split()) a, b = map(int, input().split(':')) s = False while 1: if a//10 in k and a%10 in k and b//10 in k and b%10 in k: if k[b%10]*10+k[b//10] < h and k[a%10]*10+k[a//10] < m: ...
PYTHON3
1493_B. Planet Lapituletti
The time on the planet Lapituletti goes the same way it goes on Earth but a day lasts h hours and each hour lasts m minutes. The inhabitants of that planet use digital clocks similar to earth ones. Clocks display time in a format HH:MM (the number of hours in decimal is displayed first, then (after the colon) follows t...
2
8
import java.util.*; import java.io.*; public class MyClass { static PrintWriter w; public static void main(String args[]) { Scanner sc = new Scanner(System.in); w=new PrintWriter(System.out); int test=Integer.parseInt(sc.nextLine()); A: while(tes...
JAVA
1493_B. Planet Lapituletti
The time on the planet Lapituletti goes the same way it goes on Earth but a day lasts h hours and each hour lasts m minutes. The inhabitants of that planet use digital clocks similar to earth ones. Clocks display time in a format HH:MM (the number of hours in decimal is displayed first, then (after the colon) follows t...
2
8
T = int(input()) def work(): hmax, mmax = [int(x) for x in input().strip().split()] t = input().strip() h, m = [int(x) for x in t.split(":")] swp = { "0": "0", "1": "1", "2": "5", "5": "2", "8": "8", ":": ":", } def good(h, m): cur = f"{...
PYTHON3
1493_B. Planet Lapituletti
The time on the planet Lapituletti goes the same way it goes on Earth but a day lasts h hours and each hour lasts m minutes. The inhabitants of that planet use digital clocks similar to earth ones. Clocks display time in a format HH:MM (the number of hours in decimal is displayed first, then (after the colon) follows t...
2
8
import java.util.*; import java.io.*; import java.lang.Math.*; public class KickStart2020 { static class FastReader { BufferedReader br; StringTokenizer st; public FastReader() { br = new BufferedReader( new InputStreamReader(System.in)); } ...
JAVA
1493_B. Planet Lapituletti
The time on the planet Lapituletti goes the same way it goes on Earth but a day lasts h hours and each hour lasts m minutes. The inhabitants of that planet use digital clocks similar to earth ones. Clocks display time in a format HH:MM (the number of hours in decimal is displayed first, then (after the colon) follows t...
2
8
import java.util.*; import java.lang.*; import java.io.*; public class Main { PrintWriter out = new PrintWriter(System.out); BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer tok = new StringTokenizer(""); String next() throws IOException { if (!tok.hasMoreToke...
JAVA
1493_B. Planet Lapituletti
The time on the planet Lapituletti goes the same way it goes on Earth but a day lasts h hours and each hour lasts m minutes. The inhabitants of that planet use digital clocks similar to earth ones. Clocks display time in a format HH:MM (the number of hours in decimal is displayed first, then (after the colon) follows t...
2
8
import java.util.*; import java.io.*; import java.text.DecimalFormat; public class pplanet { static DecimalFormat df1 = new DecimalFormat("#.000000"); static DecimalFormat df = new DecimalFormat("#.######"); static boolean printing=false; static int N; static int total=0; public static void main(String[] args...
JAVA
1493_B. Planet Lapituletti
The time on the planet Lapituletti goes the same way it goes on Earth but a day lasts h hours and each hour lasts m minutes. The inhabitants of that planet use digital clocks similar to earth ones. Clocks display time in a format HH:MM (the number of hours in decimal is displayed first, then (after the colon) follows t...
2
8
import java.io.*; import java.util.*; public class check2 { public static int[] check(int arr[],int val) { int v=val; StringBuilder sb=new StringBuilder(); while(v>0){ int t1=v%10; if(arr[t1]==-1) return new int[]{-1,-1}; sb.append(arr[t1]); ...
JAVA
1493_B. Planet Lapituletti
The time on the planet Lapituletti goes the same way it goes on Earth but a day lasts h hours and each hour lasts m minutes. The inhabitants of that planet use digital clocks similar to earth ones. Clocks display time in a format HH:MM (the number of hours in decimal is displayed first, then (after the colon) follows t...
2
8
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.HashMap; import java.util.Map; import java.util.StringTokenizer; public class TaskB { private static Map<Integer, Integer> MIRROR_NUMS = new HashMap...
JAVA
1493_B. Planet Lapituletti
The time on the planet Lapituletti goes the same way it goes on Earth but a day lasts h hours and each hour lasts m minutes. The inhabitants of that planet use digital clocks similar to earth ones. Clocks display time in a format HH:MM (the number of hours in decimal is displayed first, then (after the colon) follows t...
2
8
N=100 a=(5,N,N,2,N,N,8,N,0,1)*6 R=lambda x=' ':map(int,input().split(x)) t,=R() while t: t-=1;h,m=R();x,y=R(':');y+=x*m;u=v=w=q=N while h<=w+q*10or v*10+u>=m:r=f'{y//m%h:02}:{y%m:02}';y+=1;u,v,_,w,q=(a[ord(x)]for x in r) print(r)
PYTHON3
1493_B. Planet Lapituletti
The time on the planet Lapituletti goes the same way it goes on Earth but a day lasts h hours and each hour lasts m minutes. The inhabitants of that planet use digital clocks similar to earth ones. Clocks display time in a format HH:MM (the number of hours in decimal is displayed first, then (after the colon) follows t...
2
8
import java.io.BufferedReader; import java.io.FileReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; import java.util.Arrays; import java.util.Random; import java.io.FileWriter; import java.io.PrintWriter; /* Solution Created: 16:34:43 06/03/2021 Custom Compe...
JAVA
1493_B. Planet Lapituletti
The time on the planet Lapituletti goes the same way it goes on Earth but a day lasts h hours and each hour lasts m minutes. The inhabitants of that planet use digital clocks similar to earth ones. Clocks display time in a format HH:MM (the number of hours in decimal is displayed first, then (after the colon) follows t...
2
8
from sys import stdin input = stdin.readline def inc(a): p = a[:] p[1] = (p[1] + 1) % m if p[1] == 0: p[0] = (p[0] + 1) % h return p; def test(a): p = a[:] p[0] = str(p[0]) p[1] = str(p[1]) for i in range(2): if len(p[i]) == 2: p[i] = p[i][::-1] else...
PYTHON3
1493_B. Planet Lapituletti
The time on the planet Lapituletti goes the same way it goes on Earth but a day lasts h hours and each hour lasts m minutes. The inhabitants of that planet use digital clocks similar to earth ones. Clocks display time in a format HH:MM (the number of hours in decimal is displayed first, then (after the colon) follows t...
2
8
#include<bits/stdc++.h> using namespace std; #define ll int long long #define mp make_pair //#define for(i,n) for(int i=0;i<n;i++) #define F first #define S second #define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); #define N 1000000007 #define pq priority queue #define pb push_back #define pf...
CPP
1493_B. Planet Lapituletti
The time on the planet Lapituletti goes the same way it goes on Earth but a day lasts h hours and each hour lasts m minutes. The inhabitants of that planet use digital clocks similar to earth ones. Clocks display time in a format HH:MM (the number of hours in decimal is displayed first, then (after the colon) follows t...
2
8
from sys import stdin def print_time(h, m): print('{:0>2d}:{:0>2d}'.format(h, m)) ref = [0, 1, 5, -1, -1, 2, -1, -1, 8, -1] for _ in range(int(input())): h, m = map(int, stdin.readline().split()) hc, mc = map(int, stdin.readline().split(':')) while True: if not any([ref[int(x)] == -1 for x ...
PYTHON
1493_B. Planet Lapituletti
The time on the planet Lapituletti goes the same way it goes on Earth but a day lasts h hours and each hour lasts m minutes. The inhabitants of that planet use digital clocks similar to earth ones. Clocks display time in a format HH:MM (the number of hours in decimal is displayed first, then (after the colon) follows t...
2
8
# MasterKali from sys import stdin from collections import Counter from math import sqrt, factorial, log10, log, floor, ceil from itertools import permutations, combinations, combinations_with_replacement input = stdin.readline def li(): return list(map(int, input().split())) def lis(): return list(map(str, input()....
PYTHON3
1493_B. Planet Lapituletti
The time on the planet Lapituletti goes the same way it goes on Earth but a day lasts h hours and each hour lasts m minutes. The inhabitants of that planet use digital clocks similar to earth ones. Clocks display time in a format HH:MM (the number of hours in decimal is displayed first, then (after the colon) follows t...
2
8
#include <bits/stdc++.h> using namespace std; #define ll long long #define pll pair<ll, ll> int rf[10], h, m; bool isValid(string s) { int n = s.size(); for(char &x : s) { if(x == ':') continue; if(rf[x - '0'] == -1) return false; else { x = '0' + rf[x - '0']; ...
CPP
1493_B. Planet Lapituletti
The time on the planet Lapituletti goes the same way it goes on Earth but a day lasts h hours and each hour lasts m minutes. The inhabitants of that planet use digital clocks similar to earth ones. Clocks display time in a format HH:MM (the number of hours in decimal is displayed first, then (after the colon) follows t...
2
8
import sys #import re #sys.stdin=open('.in','r') #sys.stdout=open('.out','w') #import math #import random #import time #sys.setrecursionlimit(int(1e6)) input = sys.stdin.readline ############ ---- USER DEFINED INPUT FUNCTIONS ---- ############ def inp(): return(int(input())) def inara(): return(list(map(int...
PYTHON3
1493_B. Planet Lapituletti
The time on the planet Lapituletti goes the same way it goes on Earth but a day lasts h hours and each hour lasts m minutes. The inhabitants of that planet use digital clocks similar to earth ones. Clocks display time in a format HH:MM (the number of hours in decimal is displayed first, then (after the colon) follows t...
2
8
t = int(input()) def transform(n): return n // 10, n % 10 def make(ch, minuts, h, m): p = {0: 0, 1: 1, 2: 5, 5: 2, 8: 8, 3: 3, 4: 4, 6: 6, 7: 7, 9: 9} bad = {3, 4, 6, 7, 9} qc, rc = transform(ch) qm, rm = transform(minuts) flag = True if not bad.intersection({qc, rc, qm, rm}): if...
PYTHON3
1493_B. Planet Lapituletti
The time on the planet Lapituletti goes the same way it goes on Earth but a day lasts h hours and each hour lasts m minutes. The inhabitants of that planet use digital clocks similar to earth ones. Clocks display time in a format HH:MM (the number of hours in decimal is displayed first, then (after the colon) follows t...
2
8
// || || |____| // // || || || // // \\__// || // #include<bits/stdc++.h> #pragma GCC optimize("Ofast") #pragma GCC target("avx,avx2,fma") #pragma GCC optimization ("unroll-loops") typedef long long int ll; typedef long double ld; #include <bitset> #define F first #define S second #define I insert #defin...
CPP
1493_B. Planet Lapituletti
The time on the planet Lapituletti goes the same way it goes on Earth but a day lasts h hours and each hour lasts m minutes. The inhabitants of that planet use digital clocks similar to earth ones. Clocks display time in a format HH:MM (the number of hours in decimal is displayed first, then (after the colon) follows t...
2
8
#include <iostream> #include <cstring> #include <cstdio> #include <algorithm> #include <queue> #include <unordered_map> #define x first #define y second using namespace std; typedef pair<int, int> PII; const int N = 100010; int n, m; int s[] = {0, 1, 2, 5, 8}; bool get(int n) { for (int i = 0; i <= 4; i ++ ) ...
CPP
1493_B. Planet Lapituletti
The time on the planet Lapituletti goes the same way it goes on Earth but a day lasts h hours and each hour lasts m minutes. The inhabitants of that planet use digital clocks similar to earth ones. Clocks display time in a format HH:MM (the number of hours in decimal is displayed first, then (after the colon) follows t...
2
8
#include<bits/stdc++.h> using namespace std; int findnext(int value){ int checkarr[10]={0,1,5,-1,-1,2,-1,-1,8,-1}; int tens = value/10; int ones = value%10; if(checkarr[tens]!=-1 && checkarr[ones]!=-1){ return checkarr[ones]*10+checkarr[tens]; } else{ return -1; } } void ch...
CPP
1493_B. Planet Lapituletti
The time on the planet Lapituletti goes the same way it goes on Earth but a day lasts h hours and each hour lasts m minutes. The inhabitants of that planet use digital clocks similar to earth ones. Clocks display time in a format HH:MM (the number of hours in decimal is displayed first, then (after the colon) follows t...
2
8
import math for _ in range(int(input())): h,m=list(map(int,input().split())) h1,m1=list(map(int,input().split(':'))) #print(h1) #print(m1) dic={1:1,2:5,5:2,8:8,0:0} dd=list(dic.keys()) i=h1 j=m1 while(True): a1=i%10 a2=math.floor(i/10) a3=j%10 a4=...
PYTHON3
1493_B. Planet Lapituletti
The time on the planet Lapituletti goes the same way it goes on Earth but a day lasts h hours and each hour lasts m minutes. The inhabitants of that planet use digital clocks similar to earth ones. Clocks display time in a format HH:MM (the number of hours in decimal is displayed first, then (after the colon) follows t...
2
8
import java.util.Scanner; public class Solution { public static int getSym(int x) { int sym[] = new int[] { 0, 1, 5, -1, -1, 2, -1, -1, 8, -1 }; int ans = 0; for (int i = 0; i < 2; i++) { int r = x % 10; if (sym[r] == -1) return -1; ans = ans * 10 + sym[r]; x = x / 10; } return ans; } pub...
JAVA
1493_B. Planet Lapituletti
The time on the planet Lapituletti goes the same way it goes on Earth but a day lasts h hours and each hour lasts m minutes. The inhabitants of that planet use digital clocks similar to earth ones. Clocks display time in a format HH:MM (the number of hours in decimal is displayed first, then (after the colon) follows t...
2
8
import sys input=sys.stdin.readline from collections import defaultdict as dc from collections import Counter from bisect import bisect_right, bisect_left import math from operator import itemgetter from heapq import heapify, heappop, heappush from queue import PriorityQueue as pq for _ in range(int(input())): h,m...
PYTHON3
1493_B. Planet Lapituletti
The time on the planet Lapituletti goes the same way it goes on Earth but a day lasts h hours and each hour lasts m minutes. The inhabitants of that planet use digital clocks similar to earth ones. Clocks display time in a format HH:MM (the number of hours in decimal is displayed first, then (after the colon) follows t...
2
8
import java.awt.Point; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.lang.reflect.Array; import java.math.BigDecimal; import java.math.BigInteger; import java.util.ArrayList; import java.util.Arrays; impo...
JAVA
1493_B. Planet Lapituletti
The time on the planet Lapituletti goes the same way it goes on Earth but a day lasts h hours and each hour lasts m minutes. The inhabitants of that planet use digital clocks similar to earth ones. Clocks display time in a format HH:MM (the number of hours in decimal is displayed first, then (after the colon) follows t...
2
8
#include<bits/stdc++.h> using namespace std; string s; int n,m=0,a,b,a1[3],b1[3]; char c; int main(){ cin>>n; for(int i=1;i<=n;i++){ int d=0,e=0; int flag=1; cin>>a>>b; cin>>s; for(int j=0;j<=1;j++){ d*=10; d+=(s[j]-'0'); } for(int j=3;j<=4;j++){ e*=10; e+=(s[j]-'0'); } for(int j=1;j<=a*...
CPP
1493_B. Planet Lapituletti
The time on the planet Lapituletti goes the same way it goes on Earth but a day lasts h hours and each hour lasts m minutes. The inhabitants of that planet use digital clocks similar to earth ones. Clocks display time in a format HH:MM (the number of hours in decimal is displayed first, then (after the colon) follows t...
2
8
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.StringTokenizer; import java.util.InputMismatchException; import java.io.IOException; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the top * * @...
JAVA
1493_B. Planet Lapituletti
The time on the planet Lapituletti goes the same way it goes on Earth but a day lasts h hours and each hour lasts m minutes. The inhabitants of that planet use digital clocks similar to earth ones. Clocks display time in a format HH:MM (the number of hours in decimal is displayed first, then (after the colon) follows t...
2
8
import java.io.*; import java.util.*; import java.math.*; import java.awt.Point; public class CFTemplate { static final long MOD = 1000000007L; //static final long MOD2 = 1000000009L; //static final long MOD = 998244353L; //static final long INF = 500000000000L; static final int INF = 1100000000...
JAVA
1493_B. Planet Lapituletti
The time on the planet Lapituletti goes the same way it goes on Earth but a day lasts h hours and each hour lasts m minutes. The inhabitants of that planet use digital clocks similar to earth ones. Clocks display time in a format HH:MM (the number of hours in decimal is displayed first, then (after the colon) follows t...
2
8
nums = {'0': '0', '1': '1', '2': '5', '5': '2', '8': '8'} def fmt(x): return str(x).rjust(2, '0') def is_valid(hh, mm, h, m): md = '' for d in (fmt(hh) + fmt(mm))[::-1]: if d not in nums: return False md += nums[d] return 0 <= int(md[:2]) < h and 0 <= int(md[2:]) < m def solve(h, ...
PYTHON
1493_B. Planet Lapituletti
The time on the planet Lapituletti goes the same way it goes on Earth but a day lasts h hours and each hour lasts m minutes. The inhabitants of that planet use digital clocks similar to earth ones. Clocks display time in a format HH:MM (the number of hours in decimal is displayed first, then (after the colon) follows t...
2
8
import java.awt.*; import java.io.*; import java.util.*; import java.util.List; public class Hell { public static void main(String[] args) throws Exception { FastReader sc = new FastReader(); int t=sc.nextInt(); while (t-->0){ int n=sc.nextInt(), m=sc.nextInt(); Stri...
JAVA
1493_B. Planet Lapituletti
The time on the planet Lapituletti goes the same way it goes on Earth but a day lasts h hours and each hour lasts m minutes. The inhabitants of that planet use digital clocks similar to earth ones. Clocks display time in a format HH:MM (the number of hours in decimal is displayed first, then (after the colon) follows t...
2
8
import java.io.*; import java.util.*; import java.math.*; import java.math.BigInteger; public final class A { static StringBuilder ans=new StringBuilder(); static FastReader in=new FastReader(); static ArrayList<ArrayList<Integer>> g,tg; static long mod=(long)1e9+7; static boolean set[],col[]; static int D...
JAVA
1493_B. Planet Lapituletti
The time on the planet Lapituletti goes the same way it goes on Earth but a day lasts h hours and each hour lasts m minutes. The inhabitants of that planet use digital clocks similar to earth ones. Clocks display time in a format HH:MM (the number of hours in decimal is displayed first, then (after the colon) follows t...
2
8
//Implemented By Aman Kotiyal Date:-06-Mar-2021 Time:-7:13:06 pm import java.io.*; import java.util.*; public class ques2 { public static void main(String[] args)throws Exception{ new ques2().run();} long mod=1000000000+7; int h; int m; void solve() throws Exception { for(int ii=ni();ii>0;ii--) { h=ni(...
JAVA
1493_B. Planet Lapituletti
The time on the planet Lapituletti goes the same way it goes on Earth but a day lasts h hours and each hour lasts m minutes. The inhabitants of that planet use digital clocks similar to earth ones. Clocks display time in a format HH:MM (the number of hours in decimal is displayed first, then (after the colon) follows t...
2
8
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.StringTokenizer; import java.io.IOException; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.InputStream; /* @author kalZor */ public class TaskB { publ...
JAVA
1493_B. Planet Lapituletti
The time on the planet Lapituletti goes the same way it goes on Earth but a day lasts h hours and each hour lasts m minutes. The inhabitants of that planet use digital clocks similar to earth ones. Clocks display time in a format HH:MM (the number of hours in decimal is displayed first, then (after the colon) follows t...
2
8
#include<bits/stdc++.h> using namespace std; int lh, lm, hh, mm; map<int, int> mi; int mp[10] = {0,1,2,5,8}; inline void init() { mi[0] = 0; mi[1] = 1; mi[2] = 5; mi[5] = 2; mi[8] = 8; } bool judge(int a, int b, int c, int d) {//判断时间是否符合题意 if(a * 10 + b >= lh) return false; if(c * 10 + d >= lm) return false; re...
CPP
1493_B. Planet Lapituletti
The time on the planet Lapituletti goes the same way it goes on Earth but a day lasts h hours and each hour lasts m minutes. The inhabitants of that planet use digital clocks similar to earth ones. Clocks display time in a format HH:MM (the number of hours in decimal is displayed first, then (after the colon) follows t...
2
8
#include <bits/stdc++.h> using namespace std; bool t[10000]; void solve(void) { int h, m, HH, MM, i, j, l; scanf("%d %d %d:%d", &h, &m, &HH, &MM); memset(t, false, sizeof(t)); for (i = 0; i < h; i++) for (j = 0; j < m; j++) { string p = to_string(i / 10) + to_string(i % 10) + to_string(j / 10) + to_str...
CPP
1493_B. Planet Lapituletti
The time on the planet Lapituletti goes the same way it goes on Earth but a day lasts h hours and each hour lasts m minutes. The inhabitants of that planet use digital clocks similar to earth ones. Clocks display time in a format HH:MM (the number of hours in decimal is displayed first, then (after the colon) follows t...
2
8
//stan hu tao //join nct ridin by first year culture reps import static java.lang.Math.max; import static java.lang.Math.min; import static java.lang.Math.abs; import java.util.*; import java.io.*; import java.math.*; public class x1493B { public static void main(String hi[]) throws Exception { tag = n...
JAVA
1493_B. Planet Lapituletti
The time on the planet Lapituletti goes the same way it goes on Earth but a day lasts h hours and each hour lasts m minutes. The inhabitants of that planet use digital clocks similar to earth ones. Clocks display time in a format HH:MM (the number of hours in decimal is displayed first, then (after the colon) follows t...
2
8
#include<bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; const ll INF = 9223372036854775807; const ll MOD = 1000000007; const long double PI = acos(-1); #define pb push_back #define mp make_pair #define all(v) v.begin(), v.end() #define o0(a) cout<<a<<" " #define o1(a) cout<<a<<"\n" #d...
CPP
1493_B. Planet Lapituletti
The time on the planet Lapituletti goes the same way it goes on Earth but a day lasts h hours and each hour lasts m minutes. The inhabitants of that planet use digital clocks similar to earth ones. Clocks display time in a format HH:MM (the number of hours in decimal is displayed first, then (after the colon) follows t...
2
8
/* JAI MATA DI */ import java.util.*; import javax.print.attribute.HashAttributeSet; import java.io.*; import java.math.BigInteger; public class CP { static class FR{ BufferedReader br; StringTokenizer st; public FR() { br = new BufferedReader(new InputStreamReader(System.in)); } String n...
JAVA
1493_B. Planet Lapituletti
The time on the planet Lapituletti goes the same way it goes on Earth but a day lasts h hours and each hour lasts m minutes. The inhabitants of that planet use digital clocks similar to earth ones. Clocks display time in a format HH:MM (the number of hours in decimal is displayed first, then (after the colon) follows t...
2
8
#include <bits/stdc++.h> using namespace std; #define time cerr << "time taken : " << (float)clock() / CLOCKS_PER_SEC << " secs" << endl; #define fast \ ios_base::sync_with_stdio(false); \ cin.tie(NULL); #define endl "\n" #define mem1(a) memset(a,-1,sizeof(a)) ; typedef unsigned long long ...
CPP
1493_B. Planet Lapituletti
The time on the planet Lapituletti goes the same way it goes on Earth but a day lasts h hours and each hour lasts m minutes. The inhabitants of that planet use digital clocks similar to earth ones. Clocks display time in a format HH:MM (the number of hours in decimal is displayed first, then (after the colon) follows t...
2
8
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.Arrays; import java.util.Random; import java.util.StringTokenizer; public class B { private static FastReader fr = new FastReader(); private static PrintWriter out=new Prin...
JAVA
1493_B. Planet Lapituletti
The time on the planet Lapituletti goes the same way it goes on Earth but a day lasts h hours and each hour lasts m minutes. The inhabitants of that planet use digital clocks similar to earth ones. Clocks display time in a format HH:MM (the number of hours in decimal is displayed first, then (after the colon) follows t...
2
8
# import sys,os,io # input = sys.stdin.readline #input = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline T = int(input()) ans = [0]*T for t in range(T): h, m = map(int, input().split()) hh, mm = input().split(':') mi = [0,1,5,100,100,2,100,100,8,100] for i in range(int(mm), m): if i<10: new_h = mi...
PYTHON3
1493_B. Planet Lapituletti
The time on the planet Lapituletti goes the same way it goes on Earth but a day lasts h hours and each hour lasts m minutes. The inhabitants of that planet use digital clocks similar to earth ones. Clocks display time in a format HH:MM (the number of hours in decimal is displayed first, then (after the colon) follows t...
2
8
import java.util.*; import java.io.*; public class B { public static class FastIO { BufferedReader br; BufferedWriter bw, be; StringTokenizer st; public FastIO() { br = new BufferedReader(new InputStreamReader(System.in)); bw = new BufferedWriter(new OutputStreamWriter(System.out)); be = new Buff...
JAVA
1493_B. Planet Lapituletti
The time on the planet Lapituletti goes the same way it goes on Earth but a day lasts h hours and each hour lasts m minutes. The inhabitants of that planet use digital clocks similar to earth ones. Clocks display time in a format HH:MM (the number of hours in decimal is displayed first, then (after the colon) follows t...
2
8
#include<bits/stdc++.h> using namespace std; int h,m;//一天h小时,1小时m分钟 int rref[10]={0,1,5,-1,-1,2,-1,-1,8,-1}; //下标是原数字,值是镜面反射后的结果 //-1表示反射后不是一个数字 bool check(int hh,int mm)//判断反射是否合法 { int cnt=0; int tmp_h=0;//反射后的小时 while(mm)//反射之后,原分钟作为小时 { if(rref[mm%10]==-1)//反射后不是一个数字 return 0; tmp_h=tmp_h*10+rref[mm...
CPP
1493_B. Planet Lapituletti
The time on the planet Lapituletti goes the same way it goes on Earth but a day lasts h hours and each hour lasts m minutes. The inhabitants of that planet use digital clocks similar to earth ones. Clocks display time in a format HH:MM (the number of hours in decimal is displayed first, then (after the colon) follows t...
2
8
import math import sys import collections import bisect import time def get_ints():return map(int, sys.stdin.readline().strip().split()) def get_list():return list(map(int, sys.stdin.readline().strip().split())) def get_string():return sys.stdin.readline().strip() import collections ans=dict() ans["0"]="0" ans["1"]="1"...
PYTHON3
1493_B. Planet Lapituletti
The time on the planet Lapituletti goes the same way it goes on Earth but a day lasts h hours and each hour lasts m minutes. The inhabitants of that planet use digital clocks similar to earth ones. Clocks display time in a format HH:MM (the number of hours in decimal is displayed first, then (after the colon) follows t...
2
8
reflected=[0,1,5,-1,-1,2,-1,-1,8,-1] def main(): def reflectTime(h1,h2,m1,m2): return [reflected[m2],reflected[m1],reflected[h2],reflected[h1]] def checkPossibleTime(h1,h2,m1,m2): if -1 in [h1,h2,m1,m2]: # reflection contains an invalid number return False hour=10*h...
PYTHON3
1493_B. Planet Lapituletti
The time on the planet Lapituletti goes the same way it goes on Earth but a day lasts h hours and each hour lasts m minutes. The inhabitants of that planet use digital clocks similar to earth ones. Clocks display time in a format HH:MM (the number of hours in decimal is displayed first, then (after the colon) follows t...
2
8
import java.util.HashMap; import java.util.Map; import java.util.Scanner; public class Main { static Scanner scanner = new Scanner(System.in); static int h, m; static Map<Character, Character> map = new HashMap<>(); public static void main(String[] args) { map.put('0', '0'); map.put('1'...
JAVA
1493_B. Planet Lapituletti
The time on the planet Lapituletti goes the same way it goes on Earth but a day lasts h hours and each hour lasts m minutes. The inhabitants of that planet use digital clocks similar to earth ones. Clocks display time in a format HH:MM (the number of hours in decimal is displayed first, then (after the colon) follows t...
2
8
##################################### import atexit, io, sys, collections, math, heapq,fractions buffer = io.BytesIO() sys.stdout = buffer @atexit.register def write(): sys.__stdout__.write(buffer.getvalue()) cookiejar = 1 ##################################### def f(h,m,hh,mm): hh,mm = int(hh), int(mm) whil...
PYTHON
1493_B. Planet Lapituletti
The time on the planet Lapituletti goes the same way it goes on Earth but a day lasts h hours and each hour lasts m minutes. The inhabitants of that planet use digital clocks similar to earth ones. Clocks display time in a format HH:MM (the number of hours in decimal is displayed first, then (after the colon) follows t...
2
8
import java.io.BufferedReader; import java.io.InputStreamReader; public class B { private static final boolean TEST_MODE = true; public static void main(String[] args) throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int T = getInt(br); for (...
JAVA
1493_B. Planet Lapituletti
The time on the planet Lapituletti goes the same way it goes on Earth but a day lasts h hours and each hour lasts m minutes. The inhabitants of that planet use digital clocks similar to earth ones. Clocks display time in a format HH:MM (the number of hours in decimal is displayed first, then (after the colon) follows t...
2
8
# Har har mahadev # author : @ harsh kanani from collections import Counter def isValid(ss, s, e): d = {'0': '0', '1': '1', '2': '5', '8': '8', '5': '2'} nss = "" f = 0 for i in ss: if (i in d): nss += d[i] else: f = 1 break if (f == 1): r...
PYTHON3
1493_B. Planet Lapituletti
The time on the planet Lapituletti goes the same way it goes on Earth but a day lasts h hours and each hour lasts m minutes. The inhabitants of that planet use digital clocks similar to earth ones. Clocks display time in a format HH:MM (the number of hours in decimal is displayed first, then (after the colon) follows t...
2
8
import java.util.*; import java.io.*; public class Main { static final int M = 1000000007; static class FastScanner { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(""); String next() { while (!st.hasMoreTokens()) try { st = new ...
JAVA
1493_B. Planet Lapituletti
The time on the planet Lapituletti goes the same way it goes on Earth but a day lasts h hours and each hour lasts m minutes. The inhabitants of that planet use digital clocks similar to earth ones. Clocks display time in a format HH:MM (the number of hours in decimal is displayed first, then (after the colon) follows t...
2
8
import java.util.ArrayList; import java.util.HashMap; import java.util.Scanner; public class Round705 { static boolean check(int h,int min,int ch,int cm,HashMap<Integer, Integer>map) { String hr=ch+""; String mn=cm+""; if(hr.length()==1) { hr="0"+hr; } if(mn.length()==1) { mn="0"+mn; } StringBuff...
JAVA
1493_B. Planet Lapituletti
The time on the planet Lapituletti goes the same way it goes on Earth but a day lasts h hours and each hour lasts m minutes. The inhabitants of that planet use digital clocks similar to earth ones. Clocks display time in a format HH:MM (the number of hours in decimal is displayed first, then (after the colon) follows t...
2
8
t = int(input()) def check(s): if '3' in s: return False if '4' in s: return False if '6' in s: return False if '7' in s: return False if '9' in s: return False s = s[::-1] s = s.replace('2', '#') s = s.replace('5', '2') ...
PYTHON3
1493_B. Planet Lapituletti
The time on the planet Lapituletti goes the same way it goes on Earth but a day lasts h hours and each hour lasts m minutes. The inhabitants of that planet use digital clocks similar to earth ones. Clocks display time in a format HH:MM (the number of hours in decimal is displayed first, then (after the colon) follows t...
2
8
def can_mirror(x): Q=set([0,1,2,5,8]) if x in Q: return True else: return False def mirror(x): if x==0: return 0 if x==1: return 1 if x==2: return 5 if x==5: return 2 if x==8: return 8 return 0 def solve(): h,m=map(i...
PYTHON3
1493_B. Planet Lapituletti
The time on the planet Lapituletti goes the same way it goes on Earth but a day lasts h hours and each hour lasts m minutes. The inhabitants of that planet use digital clocks similar to earth ones. Clocks display time in a format HH:MM (the number of hours in decimal is displayed first, then (after the colon) follows t...
2
8
# cook your dish here def inc_time(s,h,m): hh = int(s[0:2]) mm = int(s[3:]) mm = (mm+1)%m if mm == 0: hh = (hh+1)%h if(mm<10): mm = '0'+str(mm) else: mm = str(mm) if(hh<10): hh = '0'+str(hh) else: hh = str(hh) s = hh + ':' + mm #print(s) ...
PYTHON3
1493_B. Planet Lapituletti
The time on the planet Lapituletti goes the same way it goes on Earth but a day lasts h hours and each hour lasts m minutes. The inhabitants of that planet use digital clocks similar to earth ones. Clocks display time in a format HH:MM (the number of hours in decimal is displayed first, then (after the colon) follows t...
2
8
#include<bits/stdc++.h> using namespace std; #define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); typedef long long int ll; int A[]={0,1,5,-1,-1,2,-1,-1,8,-1}; bool judge(int H, int M, int h, int m) { if(A[h%10]==-1 || A[h/10]==-1 || A[m%10]==-1 ||...
CPP
1515_H. Phoenix and Bits
Phoenix loves playing with bits — specifically, by using the bitwise operations AND, OR, and XOR. He has n integers a_1, a_2, ..., a_n, and will perform q of the following queries: 1. replace all numbers a_i where l ≤ a_i ≤ r with a_i AND x; 2. replace all numbers a_i where l ≤ a_i ≤ r with a_i OR x; 3. replac...
2
14
#include <bits/stdc++.h> using namespace std; const int N = 1e7 + 5, K = 20, W = 1 << K; int n, q, tot; int ls[N], rs[N], sum[N], or0[N], or1[N], tag[N], dep[N]; void pushup(int p) { sum[p] = sum[ls[p]] + sum[rs[p]]; or0[p] = or0[ls[p]] | or0[rs[p]]; or1[p] = or1[ls[p]] | or1[rs[p]]; } void Tag(int p, int k) ...
CPP
1515_H. Phoenix and Bits
Phoenix loves playing with bits — specifically, by using the bitwise operations AND, OR, and XOR. He has n integers a_1, a_2, ..., a_n, and will perform q of the following queries: 1. replace all numbers a_i where l ≤ a_i ≤ r with a_i AND x; 2. replace all numbers a_i where l ≤ a_i ≤ r with a_i OR x; 3. replac...
2
14
#include <bits/stdc++.h> const int N = 5e6 + 5, K = 20, M = 1 << K; int n, q, tot, ls[N], rs[N], tk[N], t0[N], t1[N], ts[N], tt[N]; inline void pushup(int p) { ts[p] = ts[ls[p]] + ts[rs[p]]; t0[p] = t0[ls[p]] | t0[rs[p]]; t1[p] = t1[ls[p]] | t1[rs[p]]; } inline void tag(int p, int t) { if (!p) return; tt[p] ^=...
CPP
1515_H. Phoenix and Bits
Phoenix loves playing with bits — specifically, by using the bitwise operations AND, OR, and XOR. He has n integers a_1, a_2, ..., a_n, and will perform q of the following queries: 1. replace all numbers a_i where l ≤ a_i ≤ r with a_i AND x; 2. replace all numbers a_i where l ≤ a_i ≤ r with a_i OR x; 3. replac...
2
14
#include<bits/stdc++.h> using namespace std; const int N=1e7+7,B=(1<<20)-1; bool fl[N]; int op,l,r,x; int n,m,ql,qr,rt,ans,A,q[N],fa[N],s1[N],s2[N],ch[N][2],dep[N],f1[N],f2[N],f3[N],qt[N],qc[N]; inline bool get(int u){ return (ch[fa[u]][1]==u); } inline void upd(int u){ if(dep[u]==-1) return; if(!ch[u][1]) f1[u]=f1[...
CPP
1515_H. Phoenix and Bits
Phoenix loves playing with bits — specifically, by using the bitwise operations AND, OR, and XOR. He has n integers a_1, a_2, ..., a_n, and will perform q of the following queries: 1. replace all numbers a_i where l ≤ a_i ≤ r with a_i AND x; 2. replace all numbers a_i where l ≤ a_i ≤ r with a_i OR x; 3. replac...
2
14
#include <bits/stdc++.h> const int N = 200005, M = 1 << 20; int n, Q, rt = 0; int lc[N * 50], rc[N * 50], tagx[N * 50], tagl[N * 50], tagr[N * 50], sum[N * 50], tot = 0; void up(int o) { tagl[o] = tagl[lc[o]] | tagl[rc[o]]; tagr[o] = tagr[lc[o]] | tagr[rc[o]]; sum[o] = sum[lc[o]] + sum[rc[o]]; } void pushx(int o, in...
CPP
1515_H. Phoenix and Bits
Phoenix loves playing with bits — specifically, by using the bitwise operations AND, OR, and XOR. He has n integers a_1, a_2, ..., a_n, and will perform q of the following queries: 1. replace all numbers a_i where l ≤ a_i ≤ r with a_i AND x; 2. replace all numbers a_i where l ≤ a_i ≤ r with a_i OR x; 3. replac...
2
14
#include<iostream> #include<cstdio> #include<algorithm> #include<set> #include<vector> #include<ctime> #include<cstring> #include<map> #include<queue> #define mp make_pair #define PII pair<int,int> #define fi first #define se second #define pb push_back using namespace std; inline int read(){ int x=0,f=1; char c=getc...
CPP
1515_H. Phoenix and Bits
Phoenix loves playing with bits — specifically, by using the bitwise operations AND, OR, and XOR. He has n integers a_1, a_2, ..., a_n, and will perform q of the following queries: 1. replace all numbers a_i where l ≤ a_i ≤ r with a_i AND x; 2. replace all numbers a_i where l ≤ a_i ≤ r with a_i OR x; 3. replac...
2
14
#include <bits/stdc++.h> using namespace std; #define rep(i, a, b) for(int i = a; i < (b); ++i) #define all(x) begin(x), end(x) #define sz(x) (int)(x).size() #define debug(...) //ignore typedef long long ll; typedef pair<int, int> pii; typedef vector<int> vi; typedef long double ld; const int LEV = 22; int BIT(int x...
CPP
1515_H. Phoenix and Bits
Phoenix loves playing with bits — specifically, by using the bitwise operations AND, OR, and XOR. He has n integers a_1, a_2, ..., a_n, and will perform q of the following queries: 1. replace all numbers a_i where l ≤ a_i ≤ r with a_i AND x; 2. replace all numbers a_i where l ≤ a_i ≤ r with a_i OR x; 3. replac...
2
14
#include<bits/stdc++.h> template <typename _Tp>void read(_Tp &x){ char ch(getchar());bool f(false);while(!isdigit(ch))f|=ch==45,ch=getchar(); x=ch&15,ch=getchar();while(isdigit(ch))x=x*10+(ch&15),ch=getchar(); if(f)x=-x; } template <typename _Tp,typename... Args>void read(_Tp &t,Args &...args){read(t);read(args...);...
CPP