exec_outcome
stringclasses
1 value
code_uid
stringlengths
32
32
file_name
stringclasses
111 values
prob_desc_created_at
stringlengths
10
10
prob_desc_description
stringlengths
63
3.8k
prob_desc_memory_limit
stringclasses
18 values
source_code
stringlengths
117
65.5k
lang_cluster
stringclasses
1 value
prob_desc_sample_inputs
stringlengths
2
802
prob_desc_time_limit
stringclasses
27 values
prob_desc_sample_outputs
stringlengths
2
796
prob_desc_notes
stringlengths
4
3k
lang
stringclasses
5 values
prob_desc_input_from
stringclasses
3 values
tags
listlengths
0
11
src_uid
stringlengths
32
32
prob_desc_input_spec
stringlengths
28
2.37k
difficulty
int64
-1
3.5k
prob_desc_output_spec
stringlengths
17
1.47k
prob_desc_output_to
stringclasses
3 values
hidden_unit_tests
stringclasses
1 value
PASSED
aa07b21cee3c7a764e2a6c5ea0ad1c2c
train_109.jsonl
1661871000
There are $$$n$$$ people in a horizontal line, each looking either to the left or the right. Each person counts the number of people in the direction they are looking. The value of the line is the sum of each person's count.For example, in the arrangement LRRLL, where L stands for a person looking left and R stands for a person looking right, the counts for each person are $$$[0, 3, 2, 3, 4]$$$, and the value is $$$0+3+2+3+4=12$$$.You are given the initial arrangement of people in the line. For each $$$k$$$ from $$$1$$$ to $$$n$$$, determine the maximum value of the line if you can change the direction of at most $$$k$$$ people.
256 megabytes
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc=new Scanner(System.in); int t=sc.nextInt(); while(t-->0){ int n=sc.nextInt(); String str=sc.next(); ArrayList<Long> list=new ArrayList<>(); long osum=0; for(int i=0;i<str.length();i++){ char ch=str.charAt(i); if(ch=='L'){ long curr=i-0; long change=str.length()-1-i; if(change-curr>0) list.add(change-curr); osum+=curr; }else { long curr=str.length()-1-i; long change=i-0; if(change-curr>0) list.add(change-curr); osum+=curr; } } Collections.sort(list); for(int i=0;i<n;i++){ if(list.size()>0) { osum+=list.get(list.size()-1); System.out.print(osum+" "); list.remove(list.size()-1); } else System.out.print(osum+" "); } System.out.println(); } } }
Java
["6\n\n3\n\nLLR\n\n5\n\nLRRLL\n\n1\n\nL\n\n12\n\nLRRRLLLRLLRL\n\n10\n\nLLLLLRRRRR\n\n9\n\nLRLRLRLRL"]
2 seconds
["3 5 5 \n16 16 16 16 16 \n0 \n86 95 98 101 102 102 102 102 102 102 102 102 \n29 38 45 52 57 62 65 68 69 70 \n44 50 54 56 56 56 56 56 56"]
NoteIn the first test case: $$$k=1$$$: change the direction of $$$1$$$ person to make the line RLR. The total value is $$$2+1+0=3$$$. $$$k=2$$$: change the direction of $$$2$$$ people to make the line RLL. The total value is $$$2+1+2=5$$$. $$$k=3$$$: change the direction of $$$2$$$ people to make the line RLL. The total value is $$$2+1+2=5$$$. Note that you have to change the direction of at most $$$k$$$ people. In the second test case, it is optimal to only change the direction of the first person for all $$$k$$$ from $$$1$$$ to $$$5$$$ (that is, make the line RRRLL).
Java 11
standard input
[ "greedy", "sortings" ]
f0402399cbaf8997993ac2ee59a60696
The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \leq t \leq 100$$$) — the number of test cases. The description of the test cases follows. The first line of each test case contains an integer $$$n$$$ ($$$1 \leq n \leq 2\cdot10^5$$$) — the length of the line. The following line contains a string consisting of $$$n$$$ characters, each of which is either L or R, representing a person facing left or right, respectively — the description of the line. It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$2\cdot10^5$$$. Please note that the answer for some test cases won't fit into 32-bit integer type, so you should use at least 64-bit integer type in your programming language (like long long for C++).
1,100
For each test case, output $$$n$$$ space-separated non-negative integers — the maximum value of the line if you can change the direction of at most $$$k$$$ people for each $$$k$$$ from $$$1$$$ to $$$n$$$, inclusive.
standard output
PASSED
3e8188ec1fba5ad6a0b416f616389b13
train_109.jsonl
1661871000
There are $$$n$$$ people in a horizontal line, each looking either to the left or the right. Each person counts the number of people in the direction they are looking. The value of the line is the sum of each person's count.For example, in the arrangement LRRLL, where L stands for a person looking left and R stands for a person looking right, the counts for each person are $$$[0, 3, 2, 3, 4]$$$, and the value is $$$0+3+2+3+4=12$$$.You are given the initial arrangement of people in the line. For each $$$k$$$ from $$$1$$$ to $$$n$$$, determine the maximum value of the line if you can change the direction of at most $$$k$$$ people.
256 megabytes
import java.io.BufferedReader; import java.io.*; import java.io.InputStreamReader; import java.util.Scanner; import java.util.*; public class Yoo { static class FastReader { BufferedReader br; StringTokenizer st; public FastReader() { br = new BufferedReader(new InputStreamReader(System.in)); } String next() { while (st == null || !st.hasMoreElements()) { try { st = new StringTokenizer(br.readLine()); } catch (IOException e) { e.printStackTrace(); } } return st.nextToken(); } int nextInt() { return Integer.parseInt(next()); } long nextLong() { return Long.parseLong(next()); } double nextDouble() { return Double.parseDouble(next()); } String nextLine() { String str = ""; try { str = br.readLine(); } catch (IOException e) { e.printStackTrace(); } return str; } } public static void main(String[] args) { FastReader sc=new FastReader(); int i,j=0; int t = sc.nextInt(); while(t-->0) { int n = sc.nextInt(); String s = sc.nextLine(); int p1,p2; long ans=0; for(i=0;i<n;i++) { if(s.charAt(i)=='L') { ans+=i; } else { ans+=(n-i-1); } } //System.out.println(ans); ArrayList<Integer> al1 = new ArrayList<Integer>(); ArrayList<Integer> al2 = new ArrayList<Integer>(); if(n%2!=0) { for(i=0;i<n/2;i++) { if(s.charAt(i)=='L') al1.add(n-1-i-i); } for(i=(n/2)+1;i<n;i++) { if(s.charAt(i)=='R') al1.add(i-(n-i-1)); } } else { for(i=0;i<n/2;i++) { if(s.charAt(i)=='L') al1.add(n-1-i-i); } for(i=(n/2);i<n;i++) { if(s.charAt(i)=='R') al1.add(i-(n-i-1)); } } //System.out.println(al1); Collections.sort(al1,Collections.reverseOrder()); for(i=0;i<n;i++) { if(i>al1.size()-1) { ans+=0; } else { ans+=al1.get(i); //ans-=(n-al1.get(i)+1); } System.out.print(ans+" "); } System.out.println(); } } }
Java
["6\n\n3\n\nLLR\n\n5\n\nLRRLL\n\n1\n\nL\n\n12\n\nLRRRLLLRLLRL\n\n10\n\nLLLLLRRRRR\n\n9\n\nLRLRLRLRL"]
2 seconds
["3 5 5 \n16 16 16 16 16 \n0 \n86 95 98 101 102 102 102 102 102 102 102 102 \n29 38 45 52 57 62 65 68 69 70 \n44 50 54 56 56 56 56 56 56"]
NoteIn the first test case: $$$k=1$$$: change the direction of $$$1$$$ person to make the line RLR. The total value is $$$2+1+0=3$$$. $$$k=2$$$: change the direction of $$$2$$$ people to make the line RLL. The total value is $$$2+1+2=5$$$. $$$k=3$$$: change the direction of $$$2$$$ people to make the line RLL. The total value is $$$2+1+2=5$$$. Note that you have to change the direction of at most $$$k$$$ people. In the second test case, it is optimal to only change the direction of the first person for all $$$k$$$ from $$$1$$$ to $$$5$$$ (that is, make the line RRRLL).
Java 11
standard input
[ "greedy", "sortings" ]
f0402399cbaf8997993ac2ee59a60696
The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \leq t \leq 100$$$) — the number of test cases. The description of the test cases follows. The first line of each test case contains an integer $$$n$$$ ($$$1 \leq n \leq 2\cdot10^5$$$) — the length of the line. The following line contains a string consisting of $$$n$$$ characters, each of which is either L or R, representing a person facing left or right, respectively — the description of the line. It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$2\cdot10^5$$$. Please note that the answer for some test cases won't fit into 32-bit integer type, so you should use at least 64-bit integer type in your programming language (like long long for C++).
1,100
For each test case, output $$$n$$$ space-separated non-negative integers — the maximum value of the line if you can change the direction of at most $$$k$$$ people for each $$$k$$$ from $$$1$$$ to $$$n$$$, inclusive.
standard output
PASSED
fabf222af095c3ef009662d6c0989dc3
train_109.jsonl
1661871000
There are $$$n$$$ people in a horizontal line, each looking either to the left or the right. Each person counts the number of people in the direction they are looking. The value of the line is the sum of each person's count.For example, in the arrangement LRRLL, where L stands for a person looking left and R stands for a person looking right, the counts for each person are $$$[0, 3, 2, 3, 4]$$$, and the value is $$$0+3+2+3+4=12$$$.You are given the initial arrangement of people in the line. For each $$$k$$$ from $$$1$$$ to $$$n$$$, determine the maximum value of the line if you can change the direction of at most $$$k$$$ people.
256 megabytes
import java.io.BufferedInputStream; import java.io.File; import java.io.FileInputStream; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; /* Name of the class has to be "Main" only if the class is public. */ public class D { public static void main(String[] args) throws Exception { // your code goes here FastScanner sc = new FastScanner(); int t = sc.nextInt(); while (t-- > 0) { int n = sc.nextInt(); String s = sc.next(); Integer ch[] = new Integer[n]; long ans =0; for(int i=0;i<n;i++){ if(s.charAt(i)=='L'){ ans+=i; }else{ ans+=(n-i-1); } if(s.charAt(i)=='L'){ ch[i]=n-i-1-i; }else{ ch[i]=i-(n-i-1); } } Arrays.sort(ch,Collections.reverseOrder()); for(int i=0;i<n;i++){ if(ch[i]>0){ ans+=ch[i]; } System.out.print(ans+" "); } System.out.println(); } } public static boolean isPrime(long n) { if (n < 2) return false; if (n == 2 || n == 3) return true; if (n % 2 == 0 || n % 3 == 0) return false; long sqrtN = (long) Math.sqrt(n) + 1; for (long i = 6L; i <= sqrtN; i += 6) { if (n % (i - 1) == 0 || n % (i + 1) == 0) return false; } return true; } public static long gcd(long a, long b) { if (a > b) a = (a + b) - (b = a); if (a == 0L) return b; return gcd(b % a, a); } public static ArrayList<Integer> findDiv(int N) { //gens all divisors of N ArrayList<Integer> ls1 = new ArrayList<Integer>(); ArrayList<Integer> ls2 = new ArrayList<Integer>(); for (int i = 1; i <= (int) (Math.sqrt(N) + 0.00000001); i++) if (N % i == 0) { ls1.add(i); ls2.add(N / i); } Collections.reverse(ls2); for (int b : ls2) if (b != ls1.get(ls1.size() - 1)) ls1.add(b); return ls1; } public static void sort(int[] arr) { //because Arrays.sort() uses quicksort which is dumb //Collections.sort() uses merge sort ArrayList<Integer> ls = new ArrayList<Integer>(); for (int x : arr) ls.add(x); Collections.sort(ls); for (int i = 0; i < arr.length; i++) arr[i] = ls.get(i); } public static long power(long x, long y, long p) { //0^0 = 1 long res = 1L; x = x % p; while (y > 0) { if ((y & 1) == 1) res = (res * x) % p; y >>= 1; x = (x * x) % p; } return res; } static class FastScanner { //I don't understand how this works lmao private int BS = 1 << 16; private char NC = (char) 0; private byte[] buf = new byte[BS]; private int bId = 0, size = 0; private char c = NC; private double cnt = 1; private BufferedInputStream in; public FastScanner() { in = new BufferedInputStream(System.in, BS); } public FastScanner(String s) { try { in = new BufferedInputStream(new FileInputStream(new File(s)), BS); } catch (Exception e) { in = new BufferedInputStream(System.in, BS); } } private char getChar() { while (bId == size) { try { size = in.read(buf); } catch (Exception e) { return NC; } if (size == -1) return NC; bId = 0; } return (char) buf[bId++]; } public int nextInt() { return (int) nextLong(); } public int[] nextInts(int N) { int[] res = new int[N]; for (int i = 0; i < N; i++) { res[i] = (int) nextLong(); } return res; } public long[] nextLongs(int N) { long[] res = new long[N]; for (int i = 0; i < N; i++) { res[i] = nextLong(); } return res; } public long nextLong() { cnt = 1; boolean neg = false; if (c == NC) c = getChar(); for (; (c < '0' || c > '9'); c = getChar()) { if (c == '-') neg = true; } long res = 0; for (; c >= '0' && c <= '9'; c = getChar()) { res = (res << 3) + (res << 1) + c - '0'; cnt *= 10; } return neg ? -res : res; } public double nextDouble() { double cur = nextLong(); return c != '.' ? cur : cur + nextLong() / cnt; } public double[] nextDoubles(int N) { double[] res = new double[N]; for (int i = 0; i < N; i++) { res[i] = nextDouble(); } return res; } public String next() { StringBuilder res = new StringBuilder(); while (c <= 32) c = getChar(); while (c > 32) { res.append(c); c = getChar(); } return res.toString(); } public String nextLine() { StringBuilder res = new StringBuilder(); while (c <= 32) c = getChar(); while (c != '\n') { res.append(c); c = getChar(); } return res.toString(); } public boolean hasNext() { if (c > 32) return true; while (true) { c = getChar(); if (c == NC) return false; else if (c > 32) return true; } } } }
Java
["6\n\n3\n\nLLR\n\n5\n\nLRRLL\n\n1\n\nL\n\n12\n\nLRRRLLLRLLRL\n\n10\n\nLLLLLRRRRR\n\n9\n\nLRLRLRLRL"]
2 seconds
["3 5 5 \n16 16 16 16 16 \n0 \n86 95 98 101 102 102 102 102 102 102 102 102 \n29 38 45 52 57 62 65 68 69 70 \n44 50 54 56 56 56 56 56 56"]
NoteIn the first test case: $$$k=1$$$: change the direction of $$$1$$$ person to make the line RLR. The total value is $$$2+1+0=3$$$. $$$k=2$$$: change the direction of $$$2$$$ people to make the line RLL. The total value is $$$2+1+2=5$$$. $$$k=3$$$: change the direction of $$$2$$$ people to make the line RLL. The total value is $$$2+1+2=5$$$. Note that you have to change the direction of at most $$$k$$$ people. In the second test case, it is optimal to only change the direction of the first person for all $$$k$$$ from $$$1$$$ to $$$5$$$ (that is, make the line RRRLL).
Java 11
standard input
[ "greedy", "sortings" ]
f0402399cbaf8997993ac2ee59a60696
The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \leq t \leq 100$$$) — the number of test cases. The description of the test cases follows. The first line of each test case contains an integer $$$n$$$ ($$$1 \leq n \leq 2\cdot10^5$$$) — the length of the line. The following line contains a string consisting of $$$n$$$ characters, each of which is either L or R, representing a person facing left or right, respectively — the description of the line. It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$2\cdot10^5$$$. Please note that the answer for some test cases won't fit into 32-bit integer type, so you should use at least 64-bit integer type in your programming language (like long long for C++).
1,100
For each test case, output $$$n$$$ space-separated non-negative integers — the maximum value of the line if you can change the direction of at most $$$k$$$ people for each $$$k$$$ from $$$1$$$ to $$$n$$$, inclusive.
standard output
PASSED
8f365e600feec40903c2d3d8d6f48850
train_109.jsonl
1661871000
There are $$$n$$$ people in a horizontal line, each looking either to the left or the right. Each person counts the number of people in the direction they are looking. The value of the line is the sum of each person's count.For example, in the arrangement LRRLL, where L stands for a person looking left and R stands for a person looking right, the counts for each person are $$$[0, 3, 2, 3, 4]$$$, and the value is $$$0+3+2+3+4=12$$$.You are given the initial arrangement of people in the line. For each $$$k$$$ from $$$1$$$ to $$$n$$$, determine the maximum value of the line if you can change the direction of at most $$$k$$$ people.
256 megabytes
import java.io.*; import java.util.*; public class Main { public static void main(String[] args) throws IOException { BufferedReader bf = new BufferedReader(new InputStreamReader(System.in)); int g = Integer.parseInt(bf.readLine()); while (g-- > 0) { int a=Integer.parseInt(bf.readLine()); PriorityQueue<Integer> ka=new PriorityQueue<>((o1, o2) -> o2-o1); char[] s=bf.readLine().toCharArray(); long sum=0; for(int i=0; i<a; i++){ int x=a-i-1,y=i; if(s[i]=='L'){ ka.add(x-y); sum+=y; } else{ ka.add(y-x); sum+=x; } } while(a-->0){ if(ka.peek()>0) sum+=ka.poll(); System.out.print(sum+" "); } System.out.println(); } } }
Java
["6\n\n3\n\nLLR\n\n5\n\nLRRLL\n\n1\n\nL\n\n12\n\nLRRRLLLRLLRL\n\n10\n\nLLLLLRRRRR\n\n9\n\nLRLRLRLRL"]
2 seconds
["3 5 5 \n16 16 16 16 16 \n0 \n86 95 98 101 102 102 102 102 102 102 102 102 \n29 38 45 52 57 62 65 68 69 70 \n44 50 54 56 56 56 56 56 56"]
NoteIn the first test case: $$$k=1$$$: change the direction of $$$1$$$ person to make the line RLR. The total value is $$$2+1+0=3$$$. $$$k=2$$$: change the direction of $$$2$$$ people to make the line RLL. The total value is $$$2+1+2=5$$$. $$$k=3$$$: change the direction of $$$2$$$ people to make the line RLL. The total value is $$$2+1+2=5$$$. Note that you have to change the direction of at most $$$k$$$ people. In the second test case, it is optimal to only change the direction of the first person for all $$$k$$$ from $$$1$$$ to $$$5$$$ (that is, make the line RRRLL).
Java 11
standard input
[ "greedy", "sortings" ]
f0402399cbaf8997993ac2ee59a60696
The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \leq t \leq 100$$$) — the number of test cases. The description of the test cases follows. The first line of each test case contains an integer $$$n$$$ ($$$1 \leq n \leq 2\cdot10^5$$$) — the length of the line. The following line contains a string consisting of $$$n$$$ characters, each of which is either L or R, representing a person facing left or right, respectively — the description of the line. It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$2\cdot10^5$$$. Please note that the answer for some test cases won't fit into 32-bit integer type, so you should use at least 64-bit integer type in your programming language (like long long for C++).
1,100
For each test case, output $$$n$$$ space-separated non-negative integers — the maximum value of the line if you can change the direction of at most $$$k$$$ people for each $$$k$$$ from $$$1$$$ to $$$n$$$, inclusive.
standard output
PASSED
26f5fdd252113f0f94b1892c542ac87e
train_109.jsonl
1661871000
There are $$$n$$$ people in a horizontal line, each looking either to the left or the right. Each person counts the number of people in the direction they are looking. The value of the line is the sum of each person's count.For example, in the arrangement LRRLL, where L stands for a person looking left and R stands for a person looking right, the counts for each person are $$$[0, 3, 2, 3, 4]$$$, and the value is $$$0+3+2+3+4=12$$$.You are given the initial arrangement of people in the line. For each $$$k$$$ from $$$1$$$ to $$$n$$$, determine the maximum value of the line if you can change the direction of at most $$$k$$$ people.
256 megabytes
import java.io.BufferedReader; import java.io.FileReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.*; public class Main { static FastReader read = new FastReader(); public static void main(String[] args) throws Exception { int t = read.nextInt(); StringBuilder out = new StringBuilder(); while(t-- > 0){ int n = read.nextInt(); String s = read.nextLine(); ArrayList<Pair> canChange = getDiffBest(s); Collections.sort(canChange); long[] cumChange = new long[canChange.size()]; for(int i = 0; i < canChange.size(); i++) { if(i == 0 ) { cumChange[i] = canChange.get(i).diffInValue; continue; } cumChange[i] = cumChange[i -1] + canChange.get(i).diffInValue; } long currentAns = 0; for(int i = 0; i < s.length(); i++) { currentAns += getValue(s.charAt(i), i, s.length()); } for(int i = 0; i < s.length(); i++) { long diff = cumChange.length == 0 ? 0 : i < cumChange.length ? cumChange[i] : cumChange[cumChange.length - 1]; long ans = diff + currentAns; out.append(ans).append(' '); } out.append('\n'); } System.out.print(out); } static int getValue(char c, int index, int totalLength) { return c == 'L' ? index : totalLength - index - 1; } static int getValueDiff(String s , int index) { char orginal = s.charAt(index); int value = getValue(orginal, index, s.length()); int newValue = getValue(orginal == 'L' ? 'R' : 'L', index, s.length()); return newValue - value; } static ArrayList<Pair> getDiffBest(String s) { ArrayList<Pair> list = new ArrayList<>(); for(int i = 0; i < s.length(); i++) { char shouldBe = (s.length() % 2 != 0 && i == s.length() / 2) ? s.charAt(i) : i < (s.length() / 2) ? 'R' : 'L'; if(s.charAt(i) != shouldBe) { int diff = getValueDiff(s,i); list.add(new Pair(i, diff)); } } return list; } } class Pair implements Comparable<Pair>{ int index; int diffInValue; Pair(int index, int diffInValue) { this.index = index; this.diffInValue = diffInValue; } @Override public int compareTo(Pair o) { return o.diffInValue - this.diffInValue; } } class FastReader { BufferedReader br; StringTokenizer st; public FastReader() { br = new BufferedReader(new InputStreamReader(System.in)); } public FastReader(String fileName) throws IOException { br = new BufferedReader(new FileReader(fileName)); } String next() { while (st == null || !st.hasMoreElements()) { try { st = new StringTokenizer(br.readLine()); } catch (IOException e) { e.printStackTrace(); } } return st.nextToken(); } int nextInt() { return Integer.parseInt(next()); } long nextLong() { return Long.parseLong(next()); } double nextDouble() { return Double.parseDouble(next()); } String nextLine() { String str = ""; try { str = br.readLine(); } catch (IOException e) { e.printStackTrace(); } return str; } }
Java
["6\n\n3\n\nLLR\n\n5\n\nLRRLL\n\n1\n\nL\n\n12\n\nLRRRLLLRLLRL\n\n10\n\nLLLLLRRRRR\n\n9\n\nLRLRLRLRL"]
2 seconds
["3 5 5 \n16 16 16 16 16 \n0 \n86 95 98 101 102 102 102 102 102 102 102 102 \n29 38 45 52 57 62 65 68 69 70 \n44 50 54 56 56 56 56 56 56"]
NoteIn the first test case: $$$k=1$$$: change the direction of $$$1$$$ person to make the line RLR. The total value is $$$2+1+0=3$$$. $$$k=2$$$: change the direction of $$$2$$$ people to make the line RLL. The total value is $$$2+1+2=5$$$. $$$k=3$$$: change the direction of $$$2$$$ people to make the line RLL. The total value is $$$2+1+2=5$$$. Note that you have to change the direction of at most $$$k$$$ people. In the second test case, it is optimal to only change the direction of the first person for all $$$k$$$ from $$$1$$$ to $$$5$$$ (that is, make the line RRRLL).
Java 11
standard input
[ "greedy", "sortings" ]
f0402399cbaf8997993ac2ee59a60696
The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \leq t \leq 100$$$) — the number of test cases. The description of the test cases follows. The first line of each test case contains an integer $$$n$$$ ($$$1 \leq n \leq 2\cdot10^5$$$) — the length of the line. The following line contains a string consisting of $$$n$$$ characters, each of which is either L or R, representing a person facing left or right, respectively — the description of the line. It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$2\cdot10^5$$$. Please note that the answer for some test cases won't fit into 32-bit integer type, so you should use at least 64-bit integer type in your programming language (like long long for C++).
1,100
For each test case, output $$$n$$$ space-separated non-negative integers — the maximum value of the line if you can change the direction of at most $$$k$$$ people for each $$$k$$$ from $$$1$$$ to $$$n$$$, inclusive.
standard output
PASSED
4af1965c77dbcae144b1c0f436a09aed
train_109.jsonl
1661871000
There are $$$n$$$ people in a horizontal line, each looking either to the left or the right. Each person counts the number of people in the direction they are looking. The value of the line is the sum of each person's count.For example, in the arrangement LRRLL, where L stands for a person looking left and R stands for a person looking right, the counts for each person are $$$[0, 3, 2, 3, 4]$$$, and the value is $$$0+3+2+3+4=12$$$.You are given the initial arrangement of people in the line. For each $$$k$$$ from $$$1$$$ to $$$n$$$, determine the maximum value of the line if you can change the direction of at most $$$k$$$ people.
256 megabytes
import java.util.*; public class D { public static void main(String [] args){ Scanner sc= new Scanner(System.in); int t=sc.nextInt(); for(;t>0;t--){ int n=sc.nextInt(); long bien=0; String jeje=sc.next(); boolean flag=false; long[] result= new long[n]; int cambiaos=0; for(int i=0; i<n/2 ; i++){ int beneficio=n - 2 * i - 1; // System.out.println(beneficio); if (jeje.charAt(i) == 'L') { result[cambiaos] += beneficio; cambiaos++; bien+=i; } else bien+=(n-i-1); if( jeje.charAt(n-1-i)=='R'){ result[cambiaos] += (beneficio); cambiaos++; bien+=i; } else bien+=(n-i-1); } if(n%2!=0) bien+=n/2; // System.out.println(bien); for(int i=0; i<n; i++) { bien+=result[i]; System.out.print((bien) + " "); } System.out.println(); } } }
Java
["6\n\n3\n\nLLR\n\n5\n\nLRRLL\n\n1\n\nL\n\n12\n\nLRRRLLLRLLRL\n\n10\n\nLLLLLRRRRR\n\n9\n\nLRLRLRLRL"]
2 seconds
["3 5 5 \n16 16 16 16 16 \n0 \n86 95 98 101 102 102 102 102 102 102 102 102 \n29 38 45 52 57 62 65 68 69 70 \n44 50 54 56 56 56 56 56 56"]
NoteIn the first test case: $$$k=1$$$: change the direction of $$$1$$$ person to make the line RLR. The total value is $$$2+1+0=3$$$. $$$k=2$$$: change the direction of $$$2$$$ people to make the line RLL. The total value is $$$2+1+2=5$$$. $$$k=3$$$: change the direction of $$$2$$$ people to make the line RLL. The total value is $$$2+1+2=5$$$. Note that you have to change the direction of at most $$$k$$$ people. In the second test case, it is optimal to only change the direction of the first person for all $$$k$$$ from $$$1$$$ to $$$5$$$ (that is, make the line RRRLL).
Java 11
standard input
[ "greedy", "sortings" ]
f0402399cbaf8997993ac2ee59a60696
The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \leq t \leq 100$$$) — the number of test cases. The description of the test cases follows. The first line of each test case contains an integer $$$n$$$ ($$$1 \leq n \leq 2\cdot10^5$$$) — the length of the line. The following line contains a string consisting of $$$n$$$ characters, each of which is either L or R, representing a person facing left or right, respectively — the description of the line. It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$2\cdot10^5$$$. Please note that the answer for some test cases won't fit into 32-bit integer type, so you should use at least 64-bit integer type in your programming language (like long long for C++).
1,100
For each test case, output $$$n$$$ space-separated non-negative integers — the maximum value of the line if you can change the direction of at most $$$k$$$ people for each $$$k$$$ from $$$1$$$ to $$$n$$$, inclusive.
standard output
PASSED
b5f9e57cf2d318360b05b6f810b3cb25
train_109.jsonl
1661871000
There are $$$n$$$ people in a horizontal line, each looking either to the left or the right. Each person counts the number of people in the direction they are looking. The value of the line is the sum of each person's count.For example, in the arrangement LRRLL, where L stands for a person looking left and R stands for a person looking right, the counts for each person are $$$[0, 3, 2, 3, 4]$$$, and the value is $$$0+3+2+3+4=12$$$.You are given the initial arrangement of people in the line. For each $$$k$$$ from $$$1$$$ to $$$n$$$, determine the maximum value of the line if you can change the direction of at most $$$k$$$ people.
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class Problem4 { public static void main(String[] args) throws IOException { try (var br = new BufferedReader(new InputStreamReader(System.in))) { var numberOfTests = Integer.parseInt(br.readLine()); var sb = new StringBuilder(); while (numberOfTests > 0) { numberOfTests--; var n = Integer.parseInt(br.readLine()); var people = br.readLine(); var mid = n / 2; var prefixes = new long[mid]; var suffixes = new long[n % 2 != 0 ? mid + 1 : mid]; var pIndex = 0; for (int i = 0; i < mid; i++) { if (people.charAt(i) == 'L') { prefixes[pIndex++] = (people.length() - i - 1) - i; } } var sIndex = 0; if (n % 2 != 0) { mid = mid + 1; } for (int i = people.length() - 1; i >= mid; i--) { if (people.charAt(i) == 'R') { suffixes[sIndex++] = i - (people.length() - i - 1); } } int p = 0; int s = 0; int index = 0; var mix = new long[n]; while (p < prefixes.length && s < suffixes.length) { if (prefixes[p] >= suffixes[s]) { mix[index] = prefixes[p]; p++; } else { mix[index] = suffixes[s]; s++; } index++; } while (p < prefixes.length) { mix[index] = prefixes[p]; p++; index++; } while (s < suffixes.length) { mix[index] = suffixes[s]; s++; index++; } var sum = new long[mix.length + 1]; for (int i = 1; i <= mix.length; i++) { sum[i] = sum[i - 1] + mix[i - 1]; } var currentValue = getValue(people); for (int k = 1; k <= n; k++) { var r = getMaxValue(k, currentValue, mix, sum); sb.append(r + " "); } sb.append("\n"); } System.out.println(sb); } } private static long getValue(String people) { long value = 0L; for (int i = 0; i < people.length(); i++) { if (people.charAt(i) == 'L') { value += i; } else { value += people.length() - i - 1; } } return value; } private static long getMaxValue(int k, long currentValue, long[] mix, long[] sum) { if (k > mix.length) { return sum[sum.length - 1] + currentValue; } return sum[k] - sum[0] + currentValue; } }
Java
["6\n\n3\n\nLLR\n\n5\n\nLRRLL\n\n1\n\nL\n\n12\n\nLRRRLLLRLLRL\n\n10\n\nLLLLLRRRRR\n\n9\n\nLRLRLRLRL"]
2 seconds
["3 5 5 \n16 16 16 16 16 \n0 \n86 95 98 101 102 102 102 102 102 102 102 102 \n29 38 45 52 57 62 65 68 69 70 \n44 50 54 56 56 56 56 56 56"]
NoteIn the first test case: $$$k=1$$$: change the direction of $$$1$$$ person to make the line RLR. The total value is $$$2+1+0=3$$$. $$$k=2$$$: change the direction of $$$2$$$ people to make the line RLL. The total value is $$$2+1+2=5$$$. $$$k=3$$$: change the direction of $$$2$$$ people to make the line RLL. The total value is $$$2+1+2=5$$$. Note that you have to change the direction of at most $$$k$$$ people. In the second test case, it is optimal to only change the direction of the first person for all $$$k$$$ from $$$1$$$ to $$$5$$$ (that is, make the line RRRLL).
Java 11
standard input
[ "greedy", "sortings" ]
f0402399cbaf8997993ac2ee59a60696
The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \leq t \leq 100$$$) — the number of test cases. The description of the test cases follows. The first line of each test case contains an integer $$$n$$$ ($$$1 \leq n \leq 2\cdot10^5$$$) — the length of the line. The following line contains a string consisting of $$$n$$$ characters, each of which is either L or R, representing a person facing left or right, respectively — the description of the line. It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$2\cdot10^5$$$. Please note that the answer for some test cases won't fit into 32-bit integer type, so you should use at least 64-bit integer type in your programming language (like long long for C++).
1,100
For each test case, output $$$n$$$ space-separated non-negative integers — the maximum value of the line if you can change the direction of at most $$$k$$$ people for each $$$k$$$ from $$$1$$$ to $$$n$$$, inclusive.
standard output
PASSED
e32e25b2e1345355e98cf9ae37f0a864
train_109.jsonl
1661871000
There are $$$n$$$ people in a horizontal line, each looking either to the left or the right. Each person counts the number of people in the direction they are looking. The value of the line is the sum of each person's count.For example, in the arrangement LRRLL, where L stands for a person looking left and R stands for a person looking right, the counts for each person are $$$[0, 3, 2, 3, 4]$$$, and the value is $$$0+3+2+3+4=12$$$.You are given the initial arrangement of people in the line. For each $$$k$$$ from $$$1$$$ to $$$n$$$, determine the maximum value of the line if you can change the direction of at most $$$k$$$ people.
256 megabytes
// package CP; import java.util.*; import java.io.*; public class contest { public static void main(String[] args) throws IOException { FastReader sc = new FastReader(); BufferedWriter w = new BufferedWriter(new OutputStreamWriter(System.out)); int t = 1; t = sc.nextInt(); while (t-- != 0) { int n = sc.nextInt(); char mat[] = sc.next().toCharArray(); long cost[][] = new long[n][2]; long sum = 0L; PriorityQueue<pair> q = new PriorityQueue<pair>(new Comparator<pair>() { public int compare(pair a, pair b) { long a1 = (b.y[1] - b.y[0]); long a2 = (a.y[1] - a.y[0]); if (a1 > a2) { return 1; } else if (a1 < a2) { return -1; } else { return 0; } } }); for (int i = 0; i < n; i++) { if (mat[i] == 'L') { cost[i][0] = i; } else { cost[i][0] = n - i - 1; } sum += cost[i][0]; cost[i][1] = Math.max(i, n - i - 1); } for (int i = 0; i < n; i++) { if (cost[i][0] < cost[i][1]) { q.add(new pair(i, cost[i])); } } long ans[] = new long[n]; for (int i = 0; i < n;) { if (q.isEmpty()) { ans[i] = sum; i++; } else { pair rem = q.poll(); long y[] = rem.y; long d = Math.abs(y[1] - y[0]); sum += d; if (d != 0) { ans[i] = sum; y[0] = Math.max(y[1], y[0]); y[1] = Math.max(y[1], y[0]); i++; } } } for (int i = 0; i < n; i++) { w.write(ans[i] + " "); } w.write("\n"); } w.flush(); w.close(); } static long primeMod = 999999999999989L; static class pair { int x; long y[]; pair(int x, long y[]) { this.x = x; this.y = y; } // public boolean equals(Object o) { // if (o instanceof pair) { // pair p = (pair) o; // return x == p.x && y == p.y; // } // return false; // } // public int hashCode() { // return (Long.valueOf(x).hashCode()) * 31 + (Long.valueOf(y).hashCode()); // } // @Override public boolean equals(Object o) { // if (o == null) { // return false; // } // if (!(o instanceof Pair)) { // return false; // } // Pair obj = (Pair)o; // return (first == obj.first && second == obj.second); // } // @Override public int hashCode() { // return Objects.hash(first, second); // } } static class FastReader { BufferedReader br; StringTokenizer st; public FastReader() { br = new BufferedReader( new InputStreamReader(System.in)); } String next() { while (st == null || !st.hasMoreElements()) { try { st = new StringTokenizer(br.readLine()); } catch (IOException e) { e.printStackTrace(); } } return st.nextToken(); } int nextInt() { return Integer.parseInt(next()); } long nextLong() { return Long.parseLong(next()); } double nextDouble() { return Double.parseDouble(next()); } String nextLine() { String str = ""; try { str = br.readLine(); } catch (IOException e) { e.printStackTrace(); } return str; } } public static void swap(int arr[], int x, int y) { int t = arr[x]; arr[x] = arr[y]; arr[y] = t; } public static int gcd(int a, int b) { if (b == 0) return a; else return gcd(b, a % b); } public static long sum(long n) { return (n * (n + 1)) / 2; } static int N = 1000000; static boolean primeSeiveDp[] = new boolean[N]; public static void primeSeive() { primeSeiveDp[0] = true; primeSeiveDp[1] = true; for (int i = 2; i * i < N; i += 2) { if (primeSeiveDp[i] == false) { for (int j = i * i; j < N; j += i) { primeSeiveDp[j] = true; } } } } public static ArrayList<Integer> primeLessThan(int m) { ArrayList<Integer> primes = new ArrayList<Integer>(); for (int i = 2; i * i <= m; i++) { if (primeSeiveDp[i] == false) { primes.add(i); } } return primes; } public static ArrayList<Integer> primesList(int n, int m) { primeSeive(); ArrayList<Integer> primes = primeLessThan(m); boolean primeSeiveRange[] = new boolean[m - n + 1]; for (int pr : primes) { int nextMultiple = (n / pr) * pr; if (nextMultiple < n) { nextMultiple += pr; } for (int i = Math.max(nextMultiple, pr * pr); i <= m; i += pr) { primeSeiveRange[i - n] = true; } } ArrayList<Integer> primesRange = new ArrayList<Integer>(); for (int i = n; i <= m; i++) { if (primeSeiveRange[i - n] == false && i != 1) { primesRange.add(i); } } return primesRange; } public static HashMap<Integer, ArrayList<Integer>> findDivisors() { HashMap<Integer, ArrayList<Integer>> divisors = new HashMap<>(); for (int i = 2; i < 100000; i++) { for (int j = i; j < 100000; j += i) { ArrayList<Integer> list = divisors.getOrDefault(j, new ArrayList<Integer>()); list.add(i); divisors.put(j, list); } } return divisors; } public static int[] findprimeFact() { int seivepf[] = new int[10000000]; for (int i = 0; i < 10000000; i++) { seivepf[i] = i; } for (int i = 2; i * i < 10000000; i++) { if (seivepf[i] == i) { for (int j = i * i; j < 10000000; j += i) { if (seivepf[j] == j) seivepf[j] = i; } } } return seivepf; } public static ArrayList<Integer> primeFactors(int n) { int spf[] = findprimeFact(); ArrayList<Integer> primeFactors = new ArrayList<Integer>(); while (n != 1) { primeFactors.add(spf[n]); n = n / spf[n]; } return primeFactors; } public static long moduloMulInv(long n, long m) { // m is modulo // n and must be co-prime // n<m return binaryExpo(n, m - 2, m); } public static long mmi(long a, long m) { long pass[] = new long[2]; long g = egcd(a, m, pass); if (g != 1) { return 0L; } return (pass[0] % m + m) % m; } public static long egcd(long a, long b, long pass[]) { if (b == 0) { pass[0] = 1L; pass[1] = 0L; return a; } long g = egcd(b, a % b, pass); long x1 = pass[0]; long y1 = pass[1]; pass[0] = y1; pass[1] = x1 - y1 * (a / b); return g; } public static long binaryExpo(long a, long b, long m) { long result = 1; while (b > 0) { if ((b & 1) == 1) { // odd result = (result * 1L * a) % m; } // multiply to base a = (a * 1L * a) % m; b >>= 1; } return result; } public static long setBit(long a, long i) { // i starts from 0 return a | (1 << i); } public static long unSetBit(long a, long i) { // i starts from 0 return a & (~(1 << i)); } public static long toggleBit(long a, long i) { // i starts from 0 return a ^ (1 << i); } public static long removeRightMostSetBit(long a) { // right most set bit = a&(-a) return a - (a & (-a)); } public static long addRightMostSetBit(long a) { // right most set bit = a&(-a) return a + (a & (-a)); } }
Java
["6\n\n3\n\nLLR\n\n5\n\nLRRLL\n\n1\n\nL\n\n12\n\nLRRRLLLRLLRL\n\n10\n\nLLLLLRRRRR\n\n9\n\nLRLRLRLRL"]
2 seconds
["3 5 5 \n16 16 16 16 16 \n0 \n86 95 98 101 102 102 102 102 102 102 102 102 \n29 38 45 52 57 62 65 68 69 70 \n44 50 54 56 56 56 56 56 56"]
NoteIn the first test case: $$$k=1$$$: change the direction of $$$1$$$ person to make the line RLR. The total value is $$$2+1+0=3$$$. $$$k=2$$$: change the direction of $$$2$$$ people to make the line RLL. The total value is $$$2+1+2=5$$$. $$$k=3$$$: change the direction of $$$2$$$ people to make the line RLL. The total value is $$$2+1+2=5$$$. Note that you have to change the direction of at most $$$k$$$ people. In the second test case, it is optimal to only change the direction of the first person for all $$$k$$$ from $$$1$$$ to $$$5$$$ (that is, make the line RRRLL).
Java 11
standard input
[ "greedy", "sortings" ]
f0402399cbaf8997993ac2ee59a60696
The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \leq t \leq 100$$$) — the number of test cases. The description of the test cases follows. The first line of each test case contains an integer $$$n$$$ ($$$1 \leq n \leq 2\cdot10^5$$$) — the length of the line. The following line contains a string consisting of $$$n$$$ characters, each of which is either L or R, representing a person facing left or right, respectively — the description of the line. It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$2\cdot10^5$$$. Please note that the answer for some test cases won't fit into 32-bit integer type, so you should use at least 64-bit integer type in your programming language (like long long for C++).
1,100
For each test case, output $$$n$$$ space-separated non-negative integers — the maximum value of the line if you can change the direction of at most $$$k$$$ people for each $$$k$$$ from $$$1$$$ to $$$n$$$, inclusive.
standard output
PASSED
24ea87f24f25767730f37f9c5baff25e
train_109.jsonl
1661871000
There are $$$n$$$ people in a horizontal line, each looking either to the left or the right. Each person counts the number of people in the direction they are looking. The value of the line is the sum of each person's count.For example, in the arrangement LRRLL, where L stands for a person looking left and R stands for a person looking right, the counts for each person are $$$[0, 3, 2, 3, 4]$$$, and the value is $$$0+3+2+3+4=12$$$.You are given the initial arrangement of people in the line. For each $$$k$$$ from $$$1$$$ to $$$n$$$, determine the maximum value of the line if you can change the direction of at most $$$k$$$ people.
256 megabytes
import java.io.*; import java.util.*; import java.util.StringTokenizer; public class tatti { static class Reader { final private int BUFFER_SIZE = 1 << 16; private DataInputStream din; private byte[] buffer; private int bufferPointer, bytesRead; public Reader() { din = new DataInputStream(System.in); buffer = new byte[BUFFER_SIZE]; bufferPointer = bytesRead = 0; } public Reader(String file_name) throws IOException { din = new DataInputStream( new FileInputStream(file_name)); buffer = new byte[BUFFER_SIZE]; bufferPointer = bytesRead = 0; } public String readLine() throws IOException { byte[] buf = new byte[64]; // line length int cnt = 0, c; while ((c = read()) != -1) { if (c == '\n') { if (cnt != 0) { break; } else { continue; } } buf[cnt++] = (byte)c; } return new String(buf, 0, cnt); } public int nextInt() throws IOException { int ret = 0; byte c = read(); while (c <= ' ') { c = read(); } boolean neg = (c == '-'); if (neg) c = read(); do { ret = ret * 10 + c - '0'; } while ((c = read()) >= '0' && c <= '9'); if (neg) return -ret; return ret; } public long nextLong() throws IOException { long ret = 0; byte c = read(); while (c <= ' ') c = read(); boolean neg = (c == '-'); if (neg) c = read(); do { ret = ret * 10 + c - '0'; } while ((c = read()) >= '0' && c <= '9'); if (neg) return -ret; return ret; } public double nextDouble() throws IOException { double ret = 0, div = 1; byte c = read(); while (c <= ' ') c = read(); boolean neg = (c == '-'); if (neg) c = read(); do { ret = ret * 10 + c - '0'; } while ((c = read()) >= '0' && c <= '9'); if (c == '.') { while ((c = read()) >= '0' && c <= '9') { ret += (c - '0') / (div *= 10); } } if (neg) return -ret; return ret; } private void fillBuffer() throws IOException { bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE); if (bytesRead == -1) buffer[0] = -1; } private byte read() throws IOException { if (bufferPointer == bytesRead) fillBuffer(); return buffer[bufferPointer++]; } public void close() throws IOException { if (din == null) return; din.close(); } } public static PrintWriter out; public static void main (String[] args) throws java.lang.Exception { out = new PrintWriter(System.out); try { Scanner obj = new Scanner (System.in); //Reader obj = new Reader (); int t = obj.nextInt(); while (t > 0) { t--; int n = obj.nextInt(); String str = obj.next(); int i, j = n - 1, k = 0; long sum = 0; for (i=0;i<n;i++) { char ch = str.charAt(i); if (ch == 'L') { sum += i; } else { sum += n - i - 1; } } i = 0; while (i <= j && k <= n) { char ch1 = str.charAt(i); char ch2 = str.charAt(j); if (ch1 == 'L') { sum -= i; sum += n - i - 1; System.out.print (sum + " "); k++; i++; } else { i++; } if (ch2 == 'R') { sum -= n - j - 1; sum += j; System.out.print (sum + " "); k++; j--; } else { j--; } } while (k < n) { System.out.print (sum + " "); k++; } System.out.println (); } }catch(Exception e){ return; } out.flush(); out.close(); } }
Java
["6\n\n3\n\nLLR\n\n5\n\nLRRLL\n\n1\n\nL\n\n12\n\nLRRRLLLRLLRL\n\n10\n\nLLLLLRRRRR\n\n9\n\nLRLRLRLRL"]
2 seconds
["3 5 5 \n16 16 16 16 16 \n0 \n86 95 98 101 102 102 102 102 102 102 102 102 \n29 38 45 52 57 62 65 68 69 70 \n44 50 54 56 56 56 56 56 56"]
NoteIn the first test case: $$$k=1$$$: change the direction of $$$1$$$ person to make the line RLR. The total value is $$$2+1+0=3$$$. $$$k=2$$$: change the direction of $$$2$$$ people to make the line RLL. The total value is $$$2+1+2=5$$$. $$$k=3$$$: change the direction of $$$2$$$ people to make the line RLL. The total value is $$$2+1+2=5$$$. Note that you have to change the direction of at most $$$k$$$ people. In the second test case, it is optimal to only change the direction of the first person for all $$$k$$$ from $$$1$$$ to $$$5$$$ (that is, make the line RRRLL).
Java 11
standard input
[ "greedy", "sortings" ]
f0402399cbaf8997993ac2ee59a60696
The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \leq t \leq 100$$$) — the number of test cases. The description of the test cases follows. The first line of each test case contains an integer $$$n$$$ ($$$1 \leq n \leq 2\cdot10^5$$$) — the length of the line. The following line contains a string consisting of $$$n$$$ characters, each of which is either L or R, representing a person facing left or right, respectively — the description of the line. It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$2\cdot10^5$$$. Please note that the answer for some test cases won't fit into 32-bit integer type, so you should use at least 64-bit integer type in your programming language (like long long for C++).
1,100
For each test case, output $$$n$$$ space-separated non-negative integers — the maximum value of the line if you can change the direction of at most $$$k$$$ people for each $$$k$$$ from $$$1$$$ to $$$n$$$, inclusive.
standard output
PASSED
6710881e1b89e570897edc7e9b71a182
train_109.jsonl
1661871000
There are $$$n$$$ people in a horizontal line, each looking either to the left or the right. Each person counts the number of people in the direction they are looking. The value of the line is the sum of each person's count.For example, in the arrangement LRRLL, where L stands for a person looking left and R stands for a person looking right, the counts for each person are $$$[0, 3, 2, 3, 4]$$$, and the value is $$$0+3+2+3+4=12$$$.You are given the initial arrangement of people in the line. For each $$$k$$$ from $$$1$$$ to $$$n$$$, determine the maximum value of the line if you can change the direction of at most $$$k$$$ people.
256 megabytes
import java.io.*; // Importing Scanner class from java.util package import java.util.*; // Main Class public class Main{ // Main driver method public static void main(String[] args) { // Setting up the input stream // You can use buffered reader too Scanner sc = new Scanner(System.in); // If You Are Running Your Code // in Sublime Text then set The // System Out to output.txt and // Input Stream to input.txt // otherwise leave it as standard // ones for ONLINE JUDGE if (System.getProperty("ONLINE_JUDGE") == null) { // Try block to check for exceptions try { // Sets the Output Stream // to output.txt System.setOut(new PrintStream( new FileOutputStream("output.txt"))); // Change the input stream // to input.txt sc = new Scanner(new File("input.txt")); } // Catch block to handle the exceptions catch (Exception e) { } } int t=sc.nextInt(); for(int z=1;z<=t;z++){ int n=sc.nextInt(); int[] arr=new int[n]; String str=sc.next(); long sum=0; for(int i=0;i<str.length();i++){ char ch=str.charAt(i); if(ch=='L'){ arr[i]=i; } else{ arr[i]=str.length()-1-i; } sum+=arr[i]; // System.out.print(arr[i]+" "); } // System.out.println(); // System.out.println(sum); int a=0; int low=0,high=n-1; int mid=n/2; for(int k=1;k<=n;k++){ while(low<=high){ if(a==k) break; int left=low; int right=n-high-1; if(left<right){ if( str.charAt(low)=='L'){ sum-=arr[low]; sum+=n-low-1; a++; low++; } else if(str.charAt(low)=='R') low++; if(a==k) break; } else if(right<left){ if( str.charAt(high)=='R'){ sum-=arr[high]; sum+=high; a++; high--; } else if(str.charAt(high)=='L') high--; if(a==k) break; } else{ if( str.charAt(low)=='L'){ sum-=arr[low]; sum+=n-low-1; a++; low++; } if(a==k) break; if( str.charAt(high)=='R'){ sum-=arr[high]; sum+=high; a++; high--; } if(a==k) break; if(str.charAt(low)=='R') low++; if(str.charAt(high)=='L') high--; } } // System.out.println(low+" "+high+" "+sum); System.out.print(sum+" "); } } } }
Java
["6\n\n3\n\nLLR\n\n5\n\nLRRLL\n\n1\n\nL\n\n12\n\nLRRRLLLRLLRL\n\n10\n\nLLLLLRRRRR\n\n9\n\nLRLRLRLRL"]
2 seconds
["3 5 5 \n16 16 16 16 16 \n0 \n86 95 98 101 102 102 102 102 102 102 102 102 \n29 38 45 52 57 62 65 68 69 70 \n44 50 54 56 56 56 56 56 56"]
NoteIn the first test case: $$$k=1$$$: change the direction of $$$1$$$ person to make the line RLR. The total value is $$$2+1+0=3$$$. $$$k=2$$$: change the direction of $$$2$$$ people to make the line RLL. The total value is $$$2+1+2=5$$$. $$$k=3$$$: change the direction of $$$2$$$ people to make the line RLL. The total value is $$$2+1+2=5$$$. Note that you have to change the direction of at most $$$k$$$ people. In the second test case, it is optimal to only change the direction of the first person for all $$$k$$$ from $$$1$$$ to $$$5$$$ (that is, make the line RRRLL).
Java 11
standard input
[ "greedy", "sortings" ]
f0402399cbaf8997993ac2ee59a60696
The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \leq t \leq 100$$$) — the number of test cases. The description of the test cases follows. The first line of each test case contains an integer $$$n$$$ ($$$1 \leq n \leq 2\cdot10^5$$$) — the length of the line. The following line contains a string consisting of $$$n$$$ characters, each of which is either L or R, representing a person facing left or right, respectively — the description of the line. It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$2\cdot10^5$$$. Please note that the answer for some test cases won't fit into 32-bit integer type, so you should use at least 64-bit integer type in your programming language (like long long for C++).
1,100
For each test case, output $$$n$$$ space-separated non-negative integers — the maximum value of the line if you can change the direction of at most $$$k$$$ people for each $$$k$$$ from $$$1$$$ to $$$n$$$, inclusive.
standard output
PASSED
c0794b3c22575c3cb7e8a25f05b1a74c
train_109.jsonl
1661871000
There are $$$n$$$ people in a horizontal line, each looking either to the left or the right. Each person counts the number of people in the direction they are looking. The value of the line is the sum of each person's count.For example, in the arrangement LRRLL, where L stands for a person looking left and R stands for a person looking right, the counts for each person are $$$[0, 3, 2, 3, 4]$$$, and the value is $$$0+3+2+3+4=12$$$.You are given the initial arrangement of people in the line. For each $$$k$$$ from $$$1$$$ to $$$n$$$, determine the maximum value of the line if you can change the direction of at most $$$k$$$ people.
256 megabytes
import java.util.*; import java.io.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int t = sc.nextInt(); while (t-- > 0) { int n = sc.nextInt(); String s = sc.next(); Map<Integer,Integer> mp=new HashMap<>(); long res = 0; for (int i = 0; i < s.length(); i++) { if (s.charAt(i) == 'L') { res += i; mp.put(i,i); } else { res += n - 1 - i; mp.put(i,n-1-i); } } long last=res; int left = 0; int right = n - 1; Map<Integer, Long> map = new HashMap<>(); int curr = 1; while (left <(n/2) && right>=(n/2)) { if(n%2!=0&&(right==(n/2))){ right--; continue; } if (s.charAt(left) == 'R') left++; else if (s.charAt(right) == 'L') right--; else { int v1 = n - 1 - left; int v2 = right; if (v1 > v2) { map.put(curr, res + v1-mp.get(left)); res =res+ v1-mp.get(left); curr++; left++; } else { map.put(curr, res + v2-mp.get(right)); res =res+ v2-mp.get(right); right--; curr++; } } } if(right>=(n/2)){ while (right>=(n/2)){ if(n%2!=0&&(right==(n/2))){ right--; continue; } int v2 = right; if (s.charAt(right) == 'L') right--; else{ map.put(curr, res + v2-mp.get(right)); res += v2-mp.get(right); right--; curr++; } } } if(left<(n/2)){ while (left<(n/2)){ int v1 = n - 1 - left; if (s.charAt(left) == 'R') left++; else{ map.put(curr, res + v1-mp.get(left)); res += v1-mp.get(left); curr++; left++; } } } for (int i = 1; i <=n ; i++) { long imp=map.getOrDefault(i,-1L); if(imp==-1)imp=last; else last=imp; System.out.print(imp+" "); } System.out.println(); } } }
Java
["6\n\n3\n\nLLR\n\n5\n\nLRRLL\n\n1\n\nL\n\n12\n\nLRRRLLLRLLRL\n\n10\n\nLLLLLRRRRR\n\n9\n\nLRLRLRLRL"]
2 seconds
["3 5 5 \n16 16 16 16 16 \n0 \n86 95 98 101 102 102 102 102 102 102 102 102 \n29 38 45 52 57 62 65 68 69 70 \n44 50 54 56 56 56 56 56 56"]
NoteIn the first test case: $$$k=1$$$: change the direction of $$$1$$$ person to make the line RLR. The total value is $$$2+1+0=3$$$. $$$k=2$$$: change the direction of $$$2$$$ people to make the line RLL. The total value is $$$2+1+2=5$$$. $$$k=3$$$: change the direction of $$$2$$$ people to make the line RLL. The total value is $$$2+1+2=5$$$. Note that you have to change the direction of at most $$$k$$$ people. In the second test case, it is optimal to only change the direction of the first person for all $$$k$$$ from $$$1$$$ to $$$5$$$ (that is, make the line RRRLL).
Java 11
standard input
[ "greedy", "sortings" ]
f0402399cbaf8997993ac2ee59a60696
The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \leq t \leq 100$$$) — the number of test cases. The description of the test cases follows. The first line of each test case contains an integer $$$n$$$ ($$$1 \leq n \leq 2\cdot10^5$$$) — the length of the line. The following line contains a string consisting of $$$n$$$ characters, each of which is either L or R, representing a person facing left or right, respectively — the description of the line. It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$2\cdot10^5$$$. Please note that the answer for some test cases won't fit into 32-bit integer type, so you should use at least 64-bit integer type in your programming language (like long long for C++).
1,100
For each test case, output $$$n$$$ space-separated non-negative integers — the maximum value of the line if you can change the direction of at most $$$k$$$ people for each $$$k$$$ from $$$1$$$ to $$$n$$$, inclusive.
standard output
PASSED
7a9d1d726fb3696955279ad088a3e207
train_109.jsonl
1661871000
There are $$$n$$$ people in a horizontal line, each looking either to the left or the right. Each person counts the number of people in the direction they are looking. The value of the line is the sum of each person's count.For example, in the arrangement LRRLL, where L stands for a person looking left and R stands for a person looking right, the counts for each person are $$$[0, 3, 2, 3, 4]$$$, and the value is $$$0+3+2+3+4=12$$$.You are given the initial arrangement of people in the line. For each $$$k$$$ from $$$1$$$ to $$$n$$$, determine the maximum value of the line if you can change the direction of at most $$$k$$$ people.
256 megabytes
import java.util.*; public class D { public static void main(String[] args) { Scanner scn = new Scanner(System.in); int t = scn.nextInt(); while (t-- > 0) { int n = scn.nextInt(); String s = scn.next(); char[] ch = new char[n]; for(int i=0;i<n;i++){ ch[i] = s.charAt(i); } int[] lsum = new int[n]; int[] rsum = new int[n]; long ssf = 0; for(int i=0;i<n;i++){ lsum[i] = i; // System.out.print(lsum[i]+" "); } // System.out.println(); for(int i=0;i<n;i++){ rsum[i] = n-1-i; // System.out.print(rsum[i]+" "); } for(int i=0;i<n;i++){ if(ch[i]=='L'){ // System.out.println(i); ssf+=lsum[i]; }else{ ssf+=rsum[i]; } } // System.out.println(ssf); // int mid = (0 + n) / 2; // for (int i = 0; i < n; i++) { // int lp =-1; // // finding extreme L till mid // for (int l = 0; l <= mid; l++) { // if(ch[l]=='L') {lp=l;break;} // } // int rp = -1; // // finding extreme R from mid+1 to right // for (int r = n-1; r >= mid; r--) { // if(ch[r]=='R') {rp=r;break;} // } // long lans = lp > -1 ? ssf - psum[lp] + (n-1-lp):-(long)1e9; // long rans = rp>-1 ? ssf - psum[rp] + rp : -(long)1e9; // // System.out.println(lans+" "+rans); // if(lans==-(long)1e9 && rans==-(long)1e9 || ssf >lans && ssf>rans) {System.out.print(ssf+" "); continue;} // if(lans!=-(long)1e9 && lans>=rans) {ch[lp]='R'; ssf = lans;} // else if(rans!=-(long)1e9 ) {ch[rp] = 'L';ssf = rans;} // System.out.print(ssf+" "); // } int lp = 0; int rp = n-1; while(n-->0){ while(lp<=rp){ if(ch[lp]=='L' && ch[rp]=='L'){ ch[lp] = 'R'; ssf-=lsum[lp]; ssf+=rsum[lp]; break; } if(ch[lp]=='R' && ch[rp]=='R'){ ch[rp] = 'L'; ssf-=rsum[rp]; ssf+=lsum[rp]; break; } if(ch[lp]=='L' && ch[rp]=='R'){ ch[lp] = 'R'; ssf-=lsum[lp]; ssf+=rsum[lp]; break; } lp++; rp--; } System.out.print(ssf+" "); } System.out.println(); } } }
Java
["6\n\n3\n\nLLR\n\n5\n\nLRRLL\n\n1\n\nL\n\n12\n\nLRRRLLLRLLRL\n\n10\n\nLLLLLRRRRR\n\n9\n\nLRLRLRLRL"]
2 seconds
["3 5 5 \n16 16 16 16 16 \n0 \n86 95 98 101 102 102 102 102 102 102 102 102 \n29 38 45 52 57 62 65 68 69 70 \n44 50 54 56 56 56 56 56 56"]
NoteIn the first test case: $$$k=1$$$: change the direction of $$$1$$$ person to make the line RLR. The total value is $$$2+1+0=3$$$. $$$k=2$$$: change the direction of $$$2$$$ people to make the line RLL. The total value is $$$2+1+2=5$$$. $$$k=3$$$: change the direction of $$$2$$$ people to make the line RLL. The total value is $$$2+1+2=5$$$. Note that you have to change the direction of at most $$$k$$$ people. In the second test case, it is optimal to only change the direction of the first person for all $$$k$$$ from $$$1$$$ to $$$5$$$ (that is, make the line RRRLL).
Java 11
standard input
[ "greedy", "sortings" ]
f0402399cbaf8997993ac2ee59a60696
The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \leq t \leq 100$$$) — the number of test cases. The description of the test cases follows. The first line of each test case contains an integer $$$n$$$ ($$$1 \leq n \leq 2\cdot10^5$$$) — the length of the line. The following line contains a string consisting of $$$n$$$ characters, each of which is either L or R, representing a person facing left or right, respectively — the description of the line. It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$2\cdot10^5$$$. Please note that the answer for some test cases won't fit into 32-bit integer type, so you should use at least 64-bit integer type in your programming language (like long long for C++).
1,100
For each test case, output $$$n$$$ space-separated non-negative integers — the maximum value of the line if you can change the direction of at most $$$k$$$ people for each $$$k$$$ from $$$1$$$ to $$$n$$$, inclusive.
standard output
PASSED
07edee86ebfa6447ea816f16796feb85
train_109.jsonl
1661871000
There are $$$n$$$ people in a horizontal line, each looking either to the left or the right. Each person counts the number of people in the direction they are looking. The value of the line is the sum of each person's count.For example, in the arrangement LRRLL, where L stands for a person looking left and R stands for a person looking right, the counts for each person are $$$[0, 3, 2, 3, 4]$$$, and the value is $$$0+3+2+3+4=12$$$.You are given the initial arrangement of people in the line. For each $$$k$$$ from $$$1$$$ to $$$n$$$, determine the maximum value of the line if you can change the direction of at most $$$k$$$ people.
256 megabytes
import java.io.*; import java.util.Scanner; public class D_Line { public static void main(String[] args) { Scanner in = new Scanner(System.in); int t = in.nextInt(); while (t-- > 0) { int n = in.nextInt(); String s = in.next(); long sum = 0; int index = 0; long[] ans = new long[n]; for (int i = 0; i < n; i++) { if (s.charAt(i) == 'L') { sum += i; } else { sum += n - i - 1; } } int i = 0; int j = n - 1; while (i <= j) { if (s.charAt(i) == 'L' && i < n - j - 1) { sum = sum - i + n - i - 1; ans[index++] = sum; i++; } else if (s.charAt(i) == 'R' && i < n - j - 1) { i++; } else if (s.charAt(j) == 'R' && i > n - j - 1) { sum = sum - n + j + 1 + j; ans[index++] = sum; j--; } else if (s.charAt(j) == 'L' && i > n - j - 1) { j--; } else if (i == n - j - 1 && s.charAt(i) == 'L') { sum = sum - i + n - i - 1; ans[index++] = sum; i++; } else if (i == n - j - 1 && s.charAt(j) == 'R') { sum = sum - n + j + 1 + j; ans[index++] = sum; j--; } else if (i == n - j - 1) { i++; j--; } if (i + 1 == j) { } } for (int k = index; k < n; k++) { ans[k] = sum; } for (int k = 0; k < n; k++) { System.out.print(ans[k] + " "); } System.out.println(); } } }
Java
["6\n\n3\n\nLLR\n\n5\n\nLRRLL\n\n1\n\nL\n\n12\n\nLRRRLLLRLLRL\n\n10\n\nLLLLLRRRRR\n\n9\n\nLRLRLRLRL"]
2 seconds
["3 5 5 \n16 16 16 16 16 \n0 \n86 95 98 101 102 102 102 102 102 102 102 102 \n29 38 45 52 57 62 65 68 69 70 \n44 50 54 56 56 56 56 56 56"]
NoteIn the first test case: $$$k=1$$$: change the direction of $$$1$$$ person to make the line RLR. The total value is $$$2+1+0=3$$$. $$$k=2$$$: change the direction of $$$2$$$ people to make the line RLL. The total value is $$$2+1+2=5$$$. $$$k=3$$$: change the direction of $$$2$$$ people to make the line RLL. The total value is $$$2+1+2=5$$$. Note that you have to change the direction of at most $$$k$$$ people. In the second test case, it is optimal to only change the direction of the first person for all $$$k$$$ from $$$1$$$ to $$$5$$$ (that is, make the line RRRLL).
Java 11
standard input
[ "greedy", "sortings" ]
f0402399cbaf8997993ac2ee59a60696
The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \leq t \leq 100$$$) — the number of test cases. The description of the test cases follows. The first line of each test case contains an integer $$$n$$$ ($$$1 \leq n \leq 2\cdot10^5$$$) — the length of the line. The following line contains a string consisting of $$$n$$$ characters, each of which is either L or R, representing a person facing left or right, respectively — the description of the line. It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$2\cdot10^5$$$. Please note that the answer for some test cases won't fit into 32-bit integer type, so you should use at least 64-bit integer type in your programming language (like long long for C++).
1,100
For each test case, output $$$n$$$ space-separated non-negative integers — the maximum value of the line if you can change the direction of at most $$$k$$$ people for each $$$k$$$ from $$$1$$$ to $$$n$$$, inclusive.
standard output
PASSED
7d9d946501b1a91ddf34dc3417c720aa
train_109.jsonl
1661871000
There are $$$n$$$ people in a horizontal line, each looking either to the left or the right. Each person counts the number of people in the direction they are looking. The value of the line is the sum of each person's count.For example, in the arrangement LRRLL, where L stands for a person looking left and R stands for a person looking right, the counts for each person are $$$[0, 3, 2, 3, 4]$$$, and the value is $$$0+3+2+3+4=12$$$.You are given the initial arrangement of people in the line. For each $$$k$$$ from $$$1$$$ to $$$n$$$, determine the maximum value of the line if you can change the direction of at most $$$k$$$ people.
256 megabytes
import java.util.*; public class Solution { static Scanner sc = new Scanner(System.in); static class word{ String data; Boolean a = false; Boolean b = false; Boolean c = false; } public static void main(String[] args) { int t = sc.nextInt(); while (t>0){t--; int n = sc.nextInt(); String str = sc.next(); StringBuilder sb = new StringBuilder(); sb.append(str); int left = 0; int right = n-1; int r = 1; long ans = count(sb); for(int i=0; i<n; ){ if(left<=right) { if (left < r) { if (sb.charAt(left) == 'L') { sb.setCharAt(left, 'R'); left++; ans -= r-1; ans += n-left; System.out.print(ans+" "); i++; } else { left++; } } else { if (sb.charAt(right) == 'R') { sb.setCharAt(right, 'L'); ans -= left-1; ans += n-r; System.out.print(ans+" "); right--;i++; r++; } else { right--; r++; } } }else { System.out.print(ans+" "); i++; } } System.out.println(); } } public static long count(StringBuilder sb){ long ans = 0; int n = sb.length(); for(int i=0; i<n; i++){ if(sb.charAt(i)=='R'){ ans += (n-1-i); }else{ ans += i; } } return ans; } }
Java
["6\n\n3\n\nLLR\n\n5\n\nLRRLL\n\n1\n\nL\n\n12\n\nLRRRLLLRLLRL\n\n10\n\nLLLLLRRRRR\n\n9\n\nLRLRLRLRL"]
2 seconds
["3 5 5 \n16 16 16 16 16 \n0 \n86 95 98 101 102 102 102 102 102 102 102 102 \n29 38 45 52 57 62 65 68 69 70 \n44 50 54 56 56 56 56 56 56"]
NoteIn the first test case: $$$k=1$$$: change the direction of $$$1$$$ person to make the line RLR. The total value is $$$2+1+0=3$$$. $$$k=2$$$: change the direction of $$$2$$$ people to make the line RLL. The total value is $$$2+1+2=5$$$. $$$k=3$$$: change the direction of $$$2$$$ people to make the line RLL. The total value is $$$2+1+2=5$$$. Note that you have to change the direction of at most $$$k$$$ people. In the second test case, it is optimal to only change the direction of the first person for all $$$k$$$ from $$$1$$$ to $$$5$$$ (that is, make the line RRRLL).
Java 11
standard input
[ "greedy", "sortings" ]
f0402399cbaf8997993ac2ee59a60696
The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \leq t \leq 100$$$) — the number of test cases. The description of the test cases follows. The first line of each test case contains an integer $$$n$$$ ($$$1 \leq n \leq 2\cdot10^5$$$) — the length of the line. The following line contains a string consisting of $$$n$$$ characters, each of which is either L or R, representing a person facing left or right, respectively — the description of the line. It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$2\cdot10^5$$$. Please note that the answer for some test cases won't fit into 32-bit integer type, so you should use at least 64-bit integer type in your programming language (like long long for C++).
1,100
For each test case, output $$$n$$$ space-separated non-negative integers — the maximum value of the line if you can change the direction of at most $$$k$$$ people for each $$$k$$$ from $$$1$$$ to $$$n$$$, inclusive.
standard output
PASSED
5e0d80a34b79ba5904c1866641c5e122
train_109.jsonl
1661871000
There are $$$n$$$ people in a horizontal line, each looking either to the left or the right. Each person counts the number of people in the direction they are looking. The value of the line is the sum of each person's count.For example, in the arrangement LRRLL, where L stands for a person looking left and R stands for a person looking right, the counts for each person are $$$[0, 3, 2, 3, 4]$$$, and the value is $$$0+3+2+3+4=12$$$.You are given the initial arrangement of people in the line. For each $$$k$$$ from $$$1$$$ to $$$n$$$, determine the maximum value of the line if you can change the direction of at most $$$k$$$ people.
256 megabytes
import java.util.*; import java.io.*; public class Solution { // For fast input output static class FastReader { BufferedReader br; StringTokenizer st; public FastReader() { try { br = new BufferedReader(new FileReader("input.txt")); PrintStream out = new PrintStream(new FileOutputStream("output.txt")); System.setOut(out); } catch (Exception e) { br = new BufferedReader(new InputStreamReader(System.in)); } } String next() { while (st == null || !st.hasMoreElements()) { try { st = new StringTokenizer(br.readLine()); } catch (IOException e) { e.printStackTrace(); } } return st.nextToken(); } int nextInt() { return Integer.parseInt(next()); } long nextLong() { return Long.parseLong(next()); } double nextDouble() { return Double.parseDouble(next()); } String nextLine() { String str = ""; try { str = br.readLine(); } catch (IOException e) { e.printStackTrace(); } return str; } } // end of fast i/o code public static void main(String[] args) { FastReader scn = new FastReader(); int t=scn.nextInt(); while(t-->0){ int n=scn.nextInt(); String s=scn.next(); long[] arr=new long[n]; PriorityQueue<int[]> pq=new PriorityQueue<>((a,b)->b[0]-a[0]); long sum=0; for(int i=0;i<n;i++){ int left=i; int right=n-i-1; if(s.charAt(i)=='L'){ // arr[i]=left; sum+=left; pq.add(new int[]{right,left}); } else { pq.add(new int[]{left,right}); sum+=right; // arr[i]=right; } } int idx=0; long prev=sum; while(pq.size()>0){ int[] p=pq.remove(); // System.out.print("["+p[0]+" "+p[1]+"]"); sum+=p[0]; sum-=p[1]; if(prev>sum){ arr[idx++]=prev; } else { prev=sum; arr[idx++]=sum; } } // System.out.println(); for(long val:arr){ System.out.print(val+" "); } System.out.println(); } } }
Java
["6\n\n3\n\nLLR\n\n5\n\nLRRLL\n\n1\n\nL\n\n12\n\nLRRRLLLRLLRL\n\n10\n\nLLLLLRRRRR\n\n9\n\nLRLRLRLRL"]
2 seconds
["3 5 5 \n16 16 16 16 16 \n0 \n86 95 98 101 102 102 102 102 102 102 102 102 \n29 38 45 52 57 62 65 68 69 70 \n44 50 54 56 56 56 56 56 56"]
NoteIn the first test case: $$$k=1$$$: change the direction of $$$1$$$ person to make the line RLR. The total value is $$$2+1+0=3$$$. $$$k=2$$$: change the direction of $$$2$$$ people to make the line RLL. The total value is $$$2+1+2=5$$$. $$$k=3$$$: change the direction of $$$2$$$ people to make the line RLL. The total value is $$$2+1+2=5$$$. Note that you have to change the direction of at most $$$k$$$ people. In the second test case, it is optimal to only change the direction of the first person for all $$$k$$$ from $$$1$$$ to $$$5$$$ (that is, make the line RRRLL).
Java 11
standard input
[ "greedy", "sortings" ]
f0402399cbaf8997993ac2ee59a60696
The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \leq t \leq 100$$$) — the number of test cases. The description of the test cases follows. The first line of each test case contains an integer $$$n$$$ ($$$1 \leq n \leq 2\cdot10^5$$$) — the length of the line. The following line contains a string consisting of $$$n$$$ characters, each of which is either L or R, representing a person facing left or right, respectively — the description of the line. It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$2\cdot10^5$$$. Please note that the answer for some test cases won't fit into 32-bit integer type, so you should use at least 64-bit integer type in your programming language (like long long for C++).
1,100
For each test case, output $$$n$$$ space-separated non-negative integers — the maximum value of the line if you can change the direction of at most $$$k$$$ people for each $$$k$$$ from $$$1$$$ to $$$n$$$, inclusive.
standard output
PASSED
b18d95c877aaf830db532f89c14186bf
train_109.jsonl
1661871000
There are $$$n$$$ people in a horizontal line, each looking either to the left or the right. Each person counts the number of people in the direction they are looking. The value of the line is the sum of each person's count.For example, in the arrangement LRRLL, where L stands for a person looking left and R stands for a person looking right, the counts for each person are $$$[0, 3, 2, 3, 4]$$$, and the value is $$$0+3+2+3+4=12$$$.You are given the initial arrangement of people in the line. For each $$$k$$$ from $$$1$$$ to $$$n$$$, determine the maximum value of the line if you can change the direction of at most $$$k$$$ people.
256 megabytes
import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.io.StreamTokenizer; import java.math.BigInteger; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; import java.util.LinkedList; import java.util.PriorityQueue; import java.util.Queue; import java.util.Random; import java.util.Scanner; import java.util.Stack; import java.util.StringTokenizer; import java.util.TreeSet; public class Main { public static void main(String[]args) throws IOException { new Main().run(); } void run() throws IOException{ new solve().setIO(System.in, System.out).run(); } public class solve extends ioTask{ int t,n,i,j,len,h,m,k,x,y; int a,b,c,d; public void run() throws IOException { t=in.in(); while(t-->0){ n=in.in(); char[]ch=in.ins().toCharArray(); long sum=0; long x; PriorityQueue<Long>q=new PriorityQueue<Long>(); for(i=0;i<n;i++) { if(ch[i]=='L')x=i; else x=n-i-1; q.add(x); sum+=x; } for(int i=0;i<n;i++) { x=q.poll(); sum-=x; sum+=Math.max(x, n-x-1); out.print(sum+" "); } out.println(); } out.close(); } } class In{ private StringTokenizer in=new StringTokenizer(""); private InputStream is; private BufferedReader bf; public In(File file) throws IOException { is=new FileInputStream(file); init(); } public In(InputStream is) throws IOException { this.is=is; init(); } private void init() throws IOException { bf=new BufferedReader(new InputStreamReader(is)); } boolean hasNext() throws IOException { return in.hasMoreTokens()||bf.ready(); } String ins() throws IOException { while(!in.hasMoreTokens()) { in=new StringTokenizer(bf.readLine()); } return in.nextToken(); } int in() throws IOException { return Integer.parseInt(ins()); } long inl() throws IOException { return Long.parseLong(ins()); } double ind() throws IOException { return Double.parseDouble(ins()); } } class Out{ PrintWriter out; private OutputStream os; private void init() { out=new PrintWriter(new BufferedWriter(new OutputStreamWriter(os))); } public Out(File file) throws IOException { os=new FileOutputStream(file); init(); } public Out(OutputStream os) throws IOException { this.os=os; init(); } } class graph{ int[]to,nxt,head,x; int cnt; void init(int n) { cnt=1; for(int i=1;i<=n;i++) { head[i]=0; } } public graph(int n,int m) { to=new int[m+1]; nxt=new int[m+1]; head=new int[n+1]; x=new int[m+1]; cnt=1; } void add(int u,int v,int x) { to[cnt]=v; nxt[cnt]=head[u]; this.x[cnt]=x; head[u]=cnt++; } } abstract class ioTask{ In in; PrintWriter out; public ioTask setIO(File in,File out) throws IOException{ this.in=new In(in); this.out=new Out(out).out; return this; } public ioTask setIO(File in,OutputStream out) throws IOException{ this.in=new In(in); this.out=new Out(out).out; return this; } public ioTask setIO(InputStream in,OutputStream out) throws IOException{ this.in=new In(in); this.out=new Out(out).out; return this; } public ioTask setIO(InputStream in,File out) throws IOException{ this.in=new In(in); this.out=new Out(out).out; return this; } void run()throws IOException{ } } }
Java
["6\n\n3\n\nLLR\n\n5\n\nLRRLL\n\n1\n\nL\n\n12\n\nLRRRLLLRLLRL\n\n10\n\nLLLLLRRRRR\n\n9\n\nLRLRLRLRL"]
2 seconds
["3 5 5 \n16 16 16 16 16 \n0 \n86 95 98 101 102 102 102 102 102 102 102 102 \n29 38 45 52 57 62 65 68 69 70 \n44 50 54 56 56 56 56 56 56"]
NoteIn the first test case: $$$k=1$$$: change the direction of $$$1$$$ person to make the line RLR. The total value is $$$2+1+0=3$$$. $$$k=2$$$: change the direction of $$$2$$$ people to make the line RLL. The total value is $$$2+1+2=5$$$. $$$k=3$$$: change the direction of $$$2$$$ people to make the line RLL. The total value is $$$2+1+2=5$$$. Note that you have to change the direction of at most $$$k$$$ people. In the second test case, it is optimal to only change the direction of the first person for all $$$k$$$ from $$$1$$$ to $$$5$$$ (that is, make the line RRRLL).
Java 11
standard input
[ "greedy", "sortings" ]
f0402399cbaf8997993ac2ee59a60696
The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \leq t \leq 100$$$) — the number of test cases. The description of the test cases follows. The first line of each test case contains an integer $$$n$$$ ($$$1 \leq n \leq 2\cdot10^5$$$) — the length of the line. The following line contains a string consisting of $$$n$$$ characters, each of which is either L or R, representing a person facing left or right, respectively — the description of the line. It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$2\cdot10^5$$$. Please note that the answer for some test cases won't fit into 32-bit integer type, so you should use at least 64-bit integer type in your programming language (like long long for C++).
1,100
For each test case, output $$$n$$$ space-separated non-negative integers — the maximum value of the line if you can change the direction of at most $$$k$$$ people for each $$$k$$$ from $$$1$$$ to $$$n$$$, inclusive.
standard output
PASSED
baa99f3de678bbf0a4e3c7b757d8c5a7
train_109.jsonl
1661871000
There are $$$n$$$ people in a horizontal line, each looking either to the left or the right. Each person counts the number of people in the direction they are looking. The value of the line is the sum of each person's count.For example, in the arrangement LRRLL, where L stands for a person looking left and R stands for a person looking right, the counts for each person are $$$[0, 3, 2, 3, 4]$$$, and the value is $$$0+3+2+3+4=12$$$.You are given the initial arrangement of people in the line. For each $$$k$$$ from $$$1$$$ to $$$n$$$, determine the maximum value of the line if you can change the direction of at most $$$k$$$ people.
256 megabytes
import java.util.Scanner; public class CF817div4{ public static void main(String[] args) { Scanner scan = new Scanner(System.in); int testCases = scan.nextInt(); while(testCases>0){ int stringLength = scan.nextInt(); String string = scan.next(); //System.out.println(xxx(string1,string2,string3)); xxx(string); testCases--; } } public static String xxx(String string){ int len=string.length(); int l=0; int r=len-1; int num=0; long all=0; for(int i=0;i<len;i++){ if(string.charAt(i)=='L') all+=i+1-1; else all+=len-(i+1); } while(l<=(len+1)/2){ if(l>=r) break; if(string.charAt(l)=='L'){ all+=len-2*l-1; System.out.println(all+" "); num++; } l++; if(string.charAt(r)=='R'){ all+=2*r+1-len; System.out.println(all+" "); num++; } r--; } while(num<len){ System.out.println(all+" "); num++; } return ""; } }
Java
["6\n\n3\n\nLLR\n\n5\n\nLRRLL\n\n1\n\nL\n\n12\n\nLRRRLLLRLLRL\n\n10\n\nLLLLLRRRRR\n\n9\n\nLRLRLRLRL"]
2 seconds
["3 5 5 \n16 16 16 16 16 \n0 \n86 95 98 101 102 102 102 102 102 102 102 102 \n29 38 45 52 57 62 65 68 69 70 \n44 50 54 56 56 56 56 56 56"]
NoteIn the first test case: $$$k=1$$$: change the direction of $$$1$$$ person to make the line RLR. The total value is $$$2+1+0=3$$$. $$$k=2$$$: change the direction of $$$2$$$ people to make the line RLL. The total value is $$$2+1+2=5$$$. $$$k=3$$$: change the direction of $$$2$$$ people to make the line RLL. The total value is $$$2+1+2=5$$$. Note that you have to change the direction of at most $$$k$$$ people. In the second test case, it is optimal to only change the direction of the first person for all $$$k$$$ from $$$1$$$ to $$$5$$$ (that is, make the line RRRLL).
Java 11
standard input
[ "greedy", "sortings" ]
f0402399cbaf8997993ac2ee59a60696
The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \leq t \leq 100$$$) — the number of test cases. The description of the test cases follows. The first line of each test case contains an integer $$$n$$$ ($$$1 \leq n \leq 2\cdot10^5$$$) — the length of the line. The following line contains a string consisting of $$$n$$$ characters, each of which is either L or R, representing a person facing left or right, respectively — the description of the line. It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$2\cdot10^5$$$. Please note that the answer for some test cases won't fit into 32-bit integer type, so you should use at least 64-bit integer type in your programming language (like long long for C++).
1,100
For each test case, output $$$n$$$ space-separated non-negative integers — the maximum value of the line if you can change the direction of at most $$$k$$$ people for each $$$k$$$ from $$$1$$$ to $$$n$$$, inclusive.
standard output
PASSED
e5a6adec762219acfee820610289d7a4
train_109.jsonl
1661871000
There are $$$n$$$ people in a horizontal line, each looking either to the left or the right. Each person counts the number of people in the direction they are looking. The value of the line is the sum of each person's count.For example, in the arrangement LRRLL, where L stands for a person looking left and R stands for a person looking right, the counts for each person are $$$[0, 3, 2, 3, 4]$$$, and the value is $$$0+3+2+3+4=12$$$.You are given the initial arrangement of people in the line. For each $$$k$$$ from $$$1$$$ to $$$n$$$, determine the maximum value of the line if you can change the direction of at most $$$k$$$ people.
256 megabytes
import java.util.*; public class D_Line { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int t = sc.nextInt(); for (int j = 0; j < t; j++) { int n = sc.nextInt(); String s = sc.next(); int[] ar = new int[n]; int[] ar2 = new int[n]; long sum1 = 0; long sum2 = 0; for (int i = 0; i < s.length(); i++) { if (s.charAt(i) == 'L') { ar[i] = i; } else { ar[i] = n - i - 1; } sum1 = sum1 + ar[i]; } int c = 0; for (int i = 0; i < n; i++) { ar2[i] = Math.max(i, n - i -1); sum2 = sum2 + ar2[i]; if (ar[i] != ar2[i]) { c++; } } int[] ar3 = new int[c]; int k = 0; for (int i = 0; i < n; i++) { if (ar[i] != ar2[i]) { ar3[k] = ar2[i] - ar[i]; k++; } } k = ar3.length; Arrays.sort(ar3); for (int i = 0; i < n; i++) { if (k <= 0) { System.out.print(sum2 + " "); } else { System.out.print(sum1 + ar3[k-1] + " "); sum1 = sum1 + ar3[k-1]; } k--; } System.out.println(); } } }
Java
["6\n\n3\n\nLLR\n\n5\n\nLRRLL\n\n1\n\nL\n\n12\n\nLRRRLLLRLLRL\n\n10\n\nLLLLLRRRRR\n\n9\n\nLRLRLRLRL"]
2 seconds
["3 5 5 \n16 16 16 16 16 \n0 \n86 95 98 101 102 102 102 102 102 102 102 102 \n29 38 45 52 57 62 65 68 69 70 \n44 50 54 56 56 56 56 56 56"]
NoteIn the first test case: $$$k=1$$$: change the direction of $$$1$$$ person to make the line RLR. The total value is $$$2+1+0=3$$$. $$$k=2$$$: change the direction of $$$2$$$ people to make the line RLL. The total value is $$$2+1+2=5$$$. $$$k=3$$$: change the direction of $$$2$$$ people to make the line RLL. The total value is $$$2+1+2=5$$$. Note that you have to change the direction of at most $$$k$$$ people. In the second test case, it is optimal to only change the direction of the first person for all $$$k$$$ from $$$1$$$ to $$$5$$$ (that is, make the line RRRLL).
Java 11
standard input
[ "greedy", "sortings" ]
f0402399cbaf8997993ac2ee59a60696
The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \leq t \leq 100$$$) — the number of test cases. The description of the test cases follows. The first line of each test case contains an integer $$$n$$$ ($$$1 \leq n \leq 2\cdot10^5$$$) — the length of the line. The following line contains a string consisting of $$$n$$$ characters, each of which is either L or R, representing a person facing left or right, respectively — the description of the line. It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$2\cdot10^5$$$. Please note that the answer for some test cases won't fit into 32-bit integer type, so you should use at least 64-bit integer type in your programming language (like long long for C++).
1,100
For each test case, output $$$n$$$ space-separated non-negative integers — the maximum value of the line if you can change the direction of at most $$$k$$$ people for each $$$k$$$ from $$$1$$$ to $$$n$$$, inclusive.
standard output
PASSED
c045e14e7cd1d17ceebd98964b4bef90
train_109.jsonl
1661871000
There are $$$n$$$ people in a horizontal line, each looking either to the left or the right. Each person counts the number of people in the direction they are looking. The value of the line is the sum of each person's count.For example, in the arrangement LRRLL, where L stands for a person looking left and R stands for a person looking right, the counts for each person are $$$[0, 3, 2, 3, 4]$$$, and the value is $$$0+3+2+3+4=12$$$.You are given the initial arrangement of people in the line. For each $$$k$$$ from $$$1$$$ to $$$n$$$, determine the maximum value of the line if you can change the direction of at most $$$k$$$ people.
256 megabytes
import java.util.*; import java.lang.*; import java.io.*; public class Main { public static void main (String[] args) throws java.lang.Exception { Scanner scn = new Scanner(System.in); int t = scn.nextInt(); while(t-- > 0){ long n = scn.nextInt(); scn.nextLine(); String x = scn.nextLine(); long sum = 0; for(int i=0;i<n;i++){ char c = x.charAt(i); if(c == 'L'){ sum += i; } else{ sum += n - 1 - i; } } PriorityQueue<Long> pq = new PriorityQueue<>(Collections.reverseOrder()); for(long i=0;i<n;i++){ if(i < n/2){ if(x.charAt((int)i) == 'L'){ pq.add(n-1-2*i); } } else{ if(x.charAt((int)i) == 'R'){ pq.add(2*i+1-n); } } } //System.out.println(pq); long[] ans = new long[(int)n]; int index = 0; while(!pq.isEmpty()){ ans[index] = pq.poll() + sum; sum = ans[index]; index++; } if(index != 0){ sum = ans[index-1]; } while(index != n){ ans[index] = sum; index++; } for(int i=0;i<n;i++){ System.out.print(ans[i] + " "); } System.out.println(); } } }
Java
["6\n\n3\n\nLLR\n\n5\n\nLRRLL\n\n1\n\nL\n\n12\n\nLRRRLLLRLLRL\n\n10\n\nLLLLLRRRRR\n\n9\n\nLRLRLRLRL"]
2 seconds
["3 5 5 \n16 16 16 16 16 \n0 \n86 95 98 101 102 102 102 102 102 102 102 102 \n29 38 45 52 57 62 65 68 69 70 \n44 50 54 56 56 56 56 56 56"]
NoteIn the first test case: $$$k=1$$$: change the direction of $$$1$$$ person to make the line RLR. The total value is $$$2+1+0=3$$$. $$$k=2$$$: change the direction of $$$2$$$ people to make the line RLL. The total value is $$$2+1+2=5$$$. $$$k=3$$$: change the direction of $$$2$$$ people to make the line RLL. The total value is $$$2+1+2=5$$$. Note that you have to change the direction of at most $$$k$$$ people. In the second test case, it is optimal to only change the direction of the first person for all $$$k$$$ from $$$1$$$ to $$$5$$$ (that is, make the line RRRLL).
Java 11
standard input
[ "greedy", "sortings" ]
f0402399cbaf8997993ac2ee59a60696
The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \leq t \leq 100$$$) — the number of test cases. The description of the test cases follows. The first line of each test case contains an integer $$$n$$$ ($$$1 \leq n \leq 2\cdot10^5$$$) — the length of the line. The following line contains a string consisting of $$$n$$$ characters, each of which is either L or R, representing a person facing left or right, respectively — the description of the line. It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$2\cdot10^5$$$. Please note that the answer for some test cases won't fit into 32-bit integer type, so you should use at least 64-bit integer type in your programming language (like long long for C++).
1,100
For each test case, output $$$n$$$ space-separated non-negative integers — the maximum value of the line if you can change the direction of at most $$$k$$$ people for each $$$k$$$ from $$$1$$$ to $$$n$$$, inclusive.
standard output
PASSED
a0d14e3787ab8e8a57c8fd49b7971d4b
train_109.jsonl
1661871000
There are $$$n$$$ people in a horizontal line, each looking either to the left or the right. Each person counts the number of people in the direction they are looking. The value of the line is the sum of each person's count.For example, in the arrangement LRRLL, where L stands for a person looking left and R stands for a person looking right, the counts for each person are $$$[0, 3, 2, 3, 4]$$$, and the value is $$$0+3+2+3+4=12$$$.You are given the initial arrangement of people in the line. For each $$$k$$$ from $$$1$$$ to $$$n$$$, determine the maximum value of the line if you can change the direction of at most $$$k$$$ people.
256 megabytes
import java.util.*; public class line { public static void main(String[] args) throws Exception { Scanner sc = new Scanner(System.in); int cases = sc.nextInt(); for( int curr = 0; curr < cases; curr++){ int n = sc.nextInt(); String s = sc.next(); char[] vals = new char[n]; for( int i = 0; i < n; i++){ vals[i] = s.charAt(i); } long score = 0; for(int i = 0; i < n; i++){ if( vals[i] == 'L') score += i; else score = score + (n - i - 1); } int k = 0; long[] scores = new long[n]; for( int i = 0; i < n; i++) scores[i] = score; for( int i = 0; i < n/2 ; i++){ if(vals[i] == 'L'){ vals[i] = 'R'; if( k == 0) scores[k] = score + (n - i - 1) - i; else scores[k] = scores[k-1] + (n - i - 1) - i; k++; } if(vals[n - i - 1] == 'R'){ vals[n - i - 1] = 'L'; if( k == 0) scores[k] = score + (n - i - 1) - i; else scores[k] = scores[k-1] + (n - i - 1) - i; k++; } } if (k > 0 ){ for ( int i = k; i < n; i++){ scores[i] = scores[k-1]; } } for( int i = 0; i < n; i++){ System.out.print(scores[i] +" "); } System.out.println(""); } } }
Java
["6\n\n3\n\nLLR\n\n5\n\nLRRLL\n\n1\n\nL\n\n12\n\nLRRRLLLRLLRL\n\n10\n\nLLLLLRRRRR\n\n9\n\nLRLRLRLRL"]
2 seconds
["3 5 5 \n16 16 16 16 16 \n0 \n86 95 98 101 102 102 102 102 102 102 102 102 \n29 38 45 52 57 62 65 68 69 70 \n44 50 54 56 56 56 56 56 56"]
NoteIn the first test case: $$$k=1$$$: change the direction of $$$1$$$ person to make the line RLR. The total value is $$$2+1+0=3$$$. $$$k=2$$$: change the direction of $$$2$$$ people to make the line RLL. The total value is $$$2+1+2=5$$$. $$$k=3$$$: change the direction of $$$2$$$ people to make the line RLL. The total value is $$$2+1+2=5$$$. Note that you have to change the direction of at most $$$k$$$ people. In the second test case, it is optimal to only change the direction of the first person for all $$$k$$$ from $$$1$$$ to $$$5$$$ (that is, make the line RRRLL).
Java 11
standard input
[ "greedy", "sortings" ]
f0402399cbaf8997993ac2ee59a60696
The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \leq t \leq 100$$$) — the number of test cases. The description of the test cases follows. The first line of each test case contains an integer $$$n$$$ ($$$1 \leq n \leq 2\cdot10^5$$$) — the length of the line. The following line contains a string consisting of $$$n$$$ characters, each of which is either L or R, representing a person facing left or right, respectively — the description of the line. It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$2\cdot10^5$$$. Please note that the answer for some test cases won't fit into 32-bit integer type, so you should use at least 64-bit integer type in your programming language (like long long for C++).
1,100
For each test case, output $$$n$$$ space-separated non-negative integers — the maximum value of the line if you can change the direction of at most $$$k$$$ people for each $$$k$$$ from $$$1$$$ to $$$n$$$, inclusive.
standard output
PASSED
901a387ebcc25bef49be25d2c2919542
train_109.jsonl
1661871000
Timur likes his name. As a spelling of his name, he allows any permutation of the letters of the name. For example, the following strings are valid spellings of his name: Timur, miurT, Trumi, mriTu. Note that the correct spelling must have uppercased T and lowercased other letters.Today he wrote string $$$s$$$ of length $$$n$$$ consisting only of uppercase or lowercase Latin letters. He asks you to check if $$$s$$$ is the correct spelling of his name.
256 megabytes
import java.util.Scanner; public class timur { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int testCases = scanner.nextInt(); int stringLength; String name; for (int i = testCases; i > 0; i--) { stringLength = scanner.nextInt(); scanner.nextLine(); name = scanner.nextLine(); if (stringLength != 5) { System.out.println("No"); } else if (name.contains("T") && name.contains("i") && name.contains("m") && name.contains("u") && name.contains("r")) { System.out.println("Yes"); } else {System.out.println("No");} } } }
Java
["10\n\n5\n\nTimur\n\n5\n\nmiurT\n\n5\n\nTrumi\n\n5\n\nmriTu\n\n5\n\ntimur\n\n4\n\nTimr\n\n6\n\nTimuur\n\n10\n\ncodeforces\n\n10\n\nTimurTimur\n\n5\n\nTIMUR"]
1 second
["YES\nYES\nYES\nYES\nNO\nNO\nNO\nNO\nNO\nNO"]
null
Java 17
standard input
[ "implementation" ]
6c137a74b36dede61037cb3b05167329
The first line of the input contains an integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The first line of each test case contains an integer $$$n$$$ $$$(1 \leq n \leq 10)$$$ — the length of string $$$s$$$. The second line of each test case contains a string $$$s$$$ consisting of only uppercase or lowercase Latin characters.
800
For each test case, output "YES" (without quotes) if $$$s$$$ satisfies the condition, and "NO" (without quotes) otherwise. You can output the answer in any case (for example, the strings "yEs", "yes", "Yes" and "YES" will be recognized as a positive answer).
standard output
PASSED
d5fbae421814ac07fb6c3a913204ab76
train_109.jsonl
1661871000
Timur likes his name. As a spelling of his name, he allows any permutation of the letters of the name. For example, the following strings are valid spellings of his name: Timur, miurT, Trumi, mriTu. Note that the correct spelling must have uppercased T and lowercased other letters.Today he wrote string $$$s$$$ of length $$$n$$$ consisting only of uppercase or lowercase Latin letters. He asks you to check if $$$s$$$ is the correct spelling of his name.
256 megabytes
import java.util.*; public class Timur { public static void main(String[] args) { Scanner in = new Scanner(System.in); int t = in.nextInt(); String s1 = "Timur"; int i; while(t-->0) { int n = in.nextInt(); String s = in.next(); if(n==5) { for(i=0;i<n;i++) { if(s1.charAt(i)==s.charAt(0) || s1.charAt(i)==s.charAt(1) || s1.charAt(i)==s.charAt(2) || s1.charAt(i)==s.charAt(3) || s1.charAt(i)==s.charAt(4)) continue; else break; } if(i==n) System.out.println("YES"); else System.out.println("NO"); } else System.out.println("NO"); } } }
Java
["10\n\n5\n\nTimur\n\n5\n\nmiurT\n\n5\n\nTrumi\n\n5\n\nmriTu\n\n5\n\ntimur\n\n4\n\nTimr\n\n6\n\nTimuur\n\n10\n\ncodeforces\n\n10\n\nTimurTimur\n\n5\n\nTIMUR"]
1 second
["YES\nYES\nYES\nYES\nNO\nNO\nNO\nNO\nNO\nNO"]
null
Java 17
standard input
[ "implementation" ]
6c137a74b36dede61037cb3b05167329
The first line of the input contains an integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The first line of each test case contains an integer $$$n$$$ $$$(1 \leq n \leq 10)$$$ — the length of string $$$s$$$. The second line of each test case contains a string $$$s$$$ consisting of only uppercase or lowercase Latin characters.
800
For each test case, output "YES" (without quotes) if $$$s$$$ satisfies the condition, and "NO" (without quotes) otherwise. You can output the answer in any case (for example, the strings "yEs", "yes", "Yes" and "YES" will be recognized as a positive answer).
standard output
PASSED
2e67c60ef196a3541faf366b7f3870a2
train_109.jsonl
1661871000
Timur likes his name. As a spelling of his name, he allows any permutation of the letters of the name. For example, the following strings are valid spellings of his name: Timur, miurT, Trumi, mriTu. Note that the correct spelling must have uppercased T and lowercased other letters.Today he wrote string $$$s$$$ of length $$$n$$$ consisting only of uppercase or lowercase Latin letters. He asks you to check if $$$s$$$ is the correct spelling of his name.
256 megabytes
import java.util.*; /** * * @author Mohammed_Ramadan */ public class SpellCheck { /** * @param args the command line arguments */ public static void main(String[] args) { Scanner input = new Scanner(System.in); int t = input.nextInt(); // String s; for (int i = 1; i <= t; i++) { int flag = 0; int flagT = 0; int flagS = 0; int len = input.nextInt(); String s = input.next(); if (s.length() != 5) { System.out.println("NO"); } else { if (s.contains("T") && s.contains("i") && s.contains("m") && s.contains("u") && s.contains("r")) { flagS = 1; } else { flagS = 0; } if (flagS == 1) { System.out.println("YES"); } else { System.out.println("NO"); } } } } }
Java
["10\n\n5\n\nTimur\n\n5\n\nmiurT\n\n5\n\nTrumi\n\n5\n\nmriTu\n\n5\n\ntimur\n\n4\n\nTimr\n\n6\n\nTimuur\n\n10\n\ncodeforces\n\n10\n\nTimurTimur\n\n5\n\nTIMUR"]
1 second
["YES\nYES\nYES\nYES\nNO\nNO\nNO\nNO\nNO\nNO"]
null
Java 17
standard input
[ "implementation" ]
6c137a74b36dede61037cb3b05167329
The first line of the input contains an integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The first line of each test case contains an integer $$$n$$$ $$$(1 \leq n \leq 10)$$$ — the length of string $$$s$$$. The second line of each test case contains a string $$$s$$$ consisting of only uppercase or lowercase Latin characters.
800
For each test case, output "YES" (without quotes) if $$$s$$$ satisfies the condition, and "NO" (without quotes) otherwise. You can output the answer in any case (for example, the strings "yEs", "yes", "Yes" and "YES" will be recognized as a positive answer).
standard output
PASSED
eac4581364af6fa0aafd654e73854403
train_109.jsonl
1661871000
Timur likes his name. As a spelling of his name, he allows any permutation of the letters of the name. For example, the following strings are valid spellings of his name: Timur, miurT, Trumi, mriTu. Note that the correct spelling must have uppercased T and lowercased other letters.Today he wrote string $$$s$$$ of length $$$n$$$ consisting only of uppercase or lowercase Latin letters. He asks you to check if $$$s$$$ is the correct spelling of his name.
256 megabytes
import java.util.*; public class Solution{ public static void solve(Scanner sc) { int n = sc.nextInt(); String s = sc.next(); int cnt=0; HashSet<Character> set = new HashSet<>(); set.add('T'); set.add('i'); set.add('m'); set.add('u'); set.add('r'); if(n!=5){ System.out.println("NO"); return; } else if(n==5){ for(int i=0;i<5;i++){ if(!set.contains(s.charAt(i))) { System.out.println("NO"); return; } else { cnt++; set.remove(s.charAt(i)); } } if(cnt==5) System.out.println("YES"); else System.out.println("NO"); return; } } public static void main(String[] args){ Scanner sc = new Scanner(System.in); int t = sc.nextInt(); while(t-->0){ solve(sc); } } }
Java
["10\n\n5\n\nTimur\n\n5\n\nmiurT\n\n5\n\nTrumi\n\n5\n\nmriTu\n\n5\n\ntimur\n\n4\n\nTimr\n\n6\n\nTimuur\n\n10\n\ncodeforces\n\n10\n\nTimurTimur\n\n5\n\nTIMUR"]
1 second
["YES\nYES\nYES\nYES\nNO\nNO\nNO\nNO\nNO\nNO"]
null
Java 17
standard input
[ "implementation" ]
6c137a74b36dede61037cb3b05167329
The first line of the input contains an integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The first line of each test case contains an integer $$$n$$$ $$$(1 \leq n \leq 10)$$$ — the length of string $$$s$$$. The second line of each test case contains a string $$$s$$$ consisting of only uppercase or lowercase Latin characters.
800
For each test case, output "YES" (without quotes) if $$$s$$$ satisfies the condition, and "NO" (without quotes) otherwise. You can output the answer in any case (for example, the strings "yEs", "yes", "Yes" and "YES" will be recognized as a positive answer).
standard output
PASSED
d64add011c4bd5c36bde764b0c5ffa1b
train_109.jsonl
1661871000
Timur likes his name. As a spelling of his name, he allows any permutation of the letters of the name. For example, the following strings are valid spellings of his name: Timur, miurT, Trumi, mriTu. Note that the correct spelling must have uppercased T and lowercased other letters.Today he wrote string $$$s$$$ of length $$$n$$$ consisting only of uppercase or lowercase Latin letters. He asks you to check if $$$s$$$ is the correct spelling of his name.
256 megabytes
import java.io.*; import java.util.Arrays; import java.util.StringTokenizer; public class A { public static void main(String[] args) { FastReader scanner = new FastReader(); char[] word = "Timur".toCharArray(); int n = scanner.nextInt(); while (n-- > 0) { int l = scanner.nextInt(); char[] anotherWord = scanner.next().toCharArray(); Arrays.sort(word); Arrays.sort(anotherWord); if (Arrays.equals(word, anotherWord)) System.out.println("YES"); else System.out.println("NO"); } } } class FastReader { BufferedReader br; StringTokenizer st; public FastReader() { br = new BufferedReader(new InputStreamReader(System.in)); } public FastReader(String file) throws FileNotFoundException { br = new BufferedReader(new FileReader(file)); } void close() throws IOException { br.close(); } String next() { while (st == null || !st.hasMoreElements()) { // null = The First time //!st.hasNoElements = After the st finish the first time try { st = new StringTokenizer(br.readLine()); } catch (IOException e) { e.printStackTrace(); } } return st.nextToken(); } int nextInt() { return Integer.parseInt(next()); } double nextDouble() { return Double.parseDouble(next()); } long nextLong() { return Long.parseLong(next()); } String nextLine() { String str = ""; try { str = br.readLine(); } catch (IOException e) { e.printStackTrace(); } return str; } boolean hasNext() { String s = null; try { s = br.readLine(); } catch (IOException e) { e.printStackTrace(); } if (s == null) return false; st = new StringTokenizer(s); return true; } }
Java
["10\n\n5\n\nTimur\n\n5\n\nmiurT\n\n5\n\nTrumi\n\n5\n\nmriTu\n\n5\n\ntimur\n\n4\n\nTimr\n\n6\n\nTimuur\n\n10\n\ncodeforces\n\n10\n\nTimurTimur\n\n5\n\nTIMUR"]
1 second
["YES\nYES\nYES\nYES\nNO\nNO\nNO\nNO\nNO\nNO"]
null
Java 17
standard input
[ "implementation" ]
6c137a74b36dede61037cb3b05167329
The first line of the input contains an integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The first line of each test case contains an integer $$$n$$$ $$$(1 \leq n \leq 10)$$$ — the length of string $$$s$$$. The second line of each test case contains a string $$$s$$$ consisting of only uppercase or lowercase Latin characters.
800
For each test case, output "YES" (without quotes) if $$$s$$$ satisfies the condition, and "NO" (without quotes) otherwise. You can output the answer in any case (for example, the strings "yEs", "yes", "Yes" and "YES" will be recognized as a positive answer).
standard output
PASSED
4f09c29f369a721f9080b24618eb0415
train_109.jsonl
1661871000
Timur likes his name. As a spelling of his name, he allows any permutation of the letters of the name. For example, the following strings are valid spellings of his name: Timur, miurT, Trumi, mriTu. Note that the correct spelling must have uppercased T and lowercased other letters.Today he wrote string $$$s$$$ of length $$$n$$$ consisting only of uppercase or lowercase Latin letters. He asks you to check if $$$s$$$ is the correct spelling of his name.
256 megabytes
import java.util.*; import java.io.*; public class Main{ public static int[] array(BufferedReader br,int n) throws IOException{ String [] values = br.readLine().split(" "); int [] arr = new int[n]; for(int i =0; i<n; i++){ arr[i] = Integer.parseInt(values[i]); } return arr; } public static void swap(int[] arr, int x, int y){ int temp = arr[x]; arr[x] = arr[y]; arr[y] = temp; } public static void print(int[][] board){ StringBuilder sb = new StringBuilder(); for(int i =0; i<board.length; i++){ for(int j = 0; j<board[0].length; j++){ sb.append(board[i][j] + " "); } sb.append("\n"); } System.out.print(sb); } public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int t = Integer.parseInt(br.readLine()); while(t-->0){ int n = Integer.parseInt(br.readLine()); String str = br.readLine(); if(n!=5){ System.out.println("NO"); continue; } boolean ans = true; boolean [] check = new boolean[n]; for(int i =0; i<n; i++){ char ch = str.charAt(i); if(ch == 'T' && check[0]==false || ch == 'i' && check[1]==false|| ch=='m' && check[2]==false|| ch=='u' && check[3]==false|| ch=='r' && check[4]==false){ if(ch=='T'){ check[0] = true; } else if(ch=='i'){ check[1] = true; } else if(ch=='m'){ check[2] = true; } else if(ch=='u'){ check[3] = true; } else if(ch=='r'){ check[4] = true; } } else{ ans = false; break; } } if(ans==true){ System.out.println("YES"); } else{ System.out.println("NO"); } } } }
Java
["10\n\n5\n\nTimur\n\n5\n\nmiurT\n\n5\n\nTrumi\n\n5\n\nmriTu\n\n5\n\ntimur\n\n4\n\nTimr\n\n6\n\nTimuur\n\n10\n\ncodeforces\n\n10\n\nTimurTimur\n\n5\n\nTIMUR"]
1 second
["YES\nYES\nYES\nYES\nNO\nNO\nNO\nNO\nNO\nNO"]
null
Java 17
standard input
[ "implementation" ]
6c137a74b36dede61037cb3b05167329
The first line of the input contains an integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The first line of each test case contains an integer $$$n$$$ $$$(1 \leq n \leq 10)$$$ — the length of string $$$s$$$. The second line of each test case contains a string $$$s$$$ consisting of only uppercase or lowercase Latin characters.
800
For each test case, output "YES" (without quotes) if $$$s$$$ satisfies the condition, and "NO" (without quotes) otherwise. You can output the answer in any case (for example, the strings "yEs", "yes", "Yes" and "YES" will be recognized as a positive answer).
standard output
PASSED
800fb8b4caaa4371cc3cc2ea64299d08
train_109.jsonl
1661871000
Timur likes his name. As a spelling of his name, he allows any permutation of the letters of the name. For example, the following strings are valid spellings of his name: Timur, miurT, Trumi, mriTu. Note that the correct spelling must have uppercased T and lowercased other letters.Today he wrote string $$$s$$$ of length $$$n$$$ consisting only of uppercase or lowercase Latin letters. He asks you to check if $$$s$$$ is the correct spelling of his name.
256 megabytes
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int k = sc.nextInt(), b; for (int i = 0; i < k; i++) { b = sc.nextInt(); String str = sc.next(); System.out.println(str.length() == 5 && str.contains("T") && str.contains("i") && str.contains("m") && str.contains("u") && str.contains("r") ? "YES" : "NO"); } } }
Java
["10\n\n5\n\nTimur\n\n5\n\nmiurT\n\n5\n\nTrumi\n\n5\n\nmriTu\n\n5\n\ntimur\n\n4\n\nTimr\n\n6\n\nTimuur\n\n10\n\ncodeforces\n\n10\n\nTimurTimur\n\n5\n\nTIMUR"]
1 second
["YES\nYES\nYES\nYES\nNO\nNO\nNO\nNO\nNO\nNO"]
null
Java 17
standard input
[ "implementation" ]
6c137a74b36dede61037cb3b05167329
The first line of the input contains an integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The first line of each test case contains an integer $$$n$$$ $$$(1 \leq n \leq 10)$$$ — the length of string $$$s$$$. The second line of each test case contains a string $$$s$$$ consisting of only uppercase or lowercase Latin characters.
800
For each test case, output "YES" (without quotes) if $$$s$$$ satisfies the condition, and "NO" (without quotes) otherwise. You can output the answer in any case (for example, the strings "yEs", "yes", "Yes" and "YES" will be recognized as a positive answer).
standard output
PASSED
09f241e198c10834501d4ad983db276e
train_109.jsonl
1661871000
Timur likes his name. As a spelling of his name, he allows any permutation of the letters of the name. For example, the following strings are valid spellings of his name: Timur, miurT, Trumi, mriTu. Note that the correct spelling must have uppercased T and lowercased other letters.Today he wrote string $$$s$$$ of length $$$n$$$ consisting only of uppercase or lowercase Latin letters. He asks you to check if $$$s$$$ is the correct spelling of his name.
256 megabytes
import java.util.Scanner; import java.util.ArrayList; import java.util.Collections; import java.util.Arrays; import java.util.HashMap; public class Solution { public static void main(String args[]) { Scanner sc=new Scanner(System.in); int t=sc.nextInt(); while(t!=0) { int n=sc.nextInt(); char test[]={'T','i','m','r','u'}; String s=sc.next(); char a[]=s.toCharArray(); Arrays.sort(a); if(Arrays.equals(test,a)) { System.out.println("YES"); } else { System.out.println("NO"); } t--; } sc.close(); } static int gcd(int a, int b) { if (a == 0 || b == 0) { return 0; } if (a == b) { return a; } if (a > b) { return gcd(a-b, b); } return gcd(a, b-a); } static boolean coPrime(int a, int b) { int min=Math.min(a,b); for(int i=min;i>=2;i--) { if(a%i==0&&b%i==0) { return false; } } return true; } }
Java
["10\n\n5\n\nTimur\n\n5\n\nmiurT\n\n5\n\nTrumi\n\n5\n\nmriTu\n\n5\n\ntimur\n\n4\n\nTimr\n\n6\n\nTimuur\n\n10\n\ncodeforces\n\n10\n\nTimurTimur\n\n5\n\nTIMUR"]
1 second
["YES\nYES\nYES\nYES\nNO\nNO\nNO\nNO\nNO\nNO"]
null
Java 17
standard input
[ "implementation" ]
6c137a74b36dede61037cb3b05167329
The first line of the input contains an integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The first line of each test case contains an integer $$$n$$$ $$$(1 \leq n \leq 10)$$$ — the length of string $$$s$$$. The second line of each test case contains a string $$$s$$$ consisting of only uppercase or lowercase Latin characters.
800
For each test case, output "YES" (without quotes) if $$$s$$$ satisfies the condition, and "NO" (without quotes) otherwise. You can output the answer in any case (for example, the strings "yEs", "yes", "Yes" and "YES" will be recognized as a positive answer).
standard output
PASSED
575b1025196fdca6ebc64f1d34c1bc8b
train_109.jsonl
1661871000
Timur likes his name. As a spelling of his name, he allows any permutation of the letters of the name. For example, the following strings are valid spellings of his name: Timur, miurT, Trumi, mriTu. Note that the correct spelling must have uppercased T and lowercased other letters.Today he wrote string $$$s$$$ of length $$$n$$$ consisting only of uppercase or lowercase Latin letters. He asks you to check if $$$s$$$ is the correct spelling of his name.
256 megabytes
import java.util.*; public class Main{ public static void main(String[] args){ Scanner sc=new Scanner(System.in); int t=sc.nextInt(); while(t-->0){ int n=sc.nextInt(); String s=sc.next(); if(n!=5){ System.out.println("NO"); } else{ char []ch=s.toCharArray(); Arrays.sort(ch); if(ch[0]=='T' && ch[1]=='i' && ch[2]=='m' && ch[3]=='r' && ch[4]=='u'){ System.out.println("YES"); } else{ System.out.println("NO"); } } } } }
Java
["10\n\n5\n\nTimur\n\n5\n\nmiurT\n\n5\n\nTrumi\n\n5\n\nmriTu\n\n5\n\ntimur\n\n4\n\nTimr\n\n6\n\nTimuur\n\n10\n\ncodeforces\n\n10\n\nTimurTimur\n\n5\n\nTIMUR"]
1 second
["YES\nYES\nYES\nYES\nNO\nNO\nNO\nNO\nNO\nNO"]
null
Java 17
standard input
[ "implementation" ]
6c137a74b36dede61037cb3b05167329
The first line of the input contains an integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The first line of each test case contains an integer $$$n$$$ $$$(1 \leq n \leq 10)$$$ — the length of string $$$s$$$. The second line of each test case contains a string $$$s$$$ consisting of only uppercase or lowercase Latin characters.
800
For each test case, output "YES" (without quotes) if $$$s$$$ satisfies the condition, and "NO" (without quotes) otherwise. You can output the answer in any case (for example, the strings "yEs", "yes", "Yes" and "YES" will be recognized as a positive answer).
standard output
PASSED
96bc40a0beb458ff43805ff0f9c39619
train_109.jsonl
1661871000
Timur likes his name. As a spelling of his name, he allows any permutation of the letters of the name. For example, the following strings are valid spellings of his name: Timur, miurT, Trumi, mriTu. Note that the correct spelling must have uppercased T and lowercased other letters.Today he wrote string $$$s$$$ of length $$$n$$$ consisting only of uppercase or lowercase Latin letters. He asks you to check if $$$s$$$ is the correct spelling of his name.
256 megabytes
import java.util.*; import java.io.*; public class Solution { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int testCase = Integer.parseInt(br.readLine()); char[] ans= {'T','i','m','r','u'}; for (int i = 0; i < testCase; i++) { int y = Integer.parseInt(br.readLine()); String x = br.readLine(); if (y==5) { char[] z =x.toCharArray(); Arrays.sort(z); if (Arrays.equals(z,ans)) System.out.println("yes"); else System.out.println("no"); } else System.out.println("No"); } } }
Java
["10\n\n5\n\nTimur\n\n5\n\nmiurT\n\n5\n\nTrumi\n\n5\n\nmriTu\n\n5\n\ntimur\n\n4\n\nTimr\n\n6\n\nTimuur\n\n10\n\ncodeforces\n\n10\n\nTimurTimur\n\n5\n\nTIMUR"]
1 second
["YES\nYES\nYES\nYES\nNO\nNO\nNO\nNO\nNO\nNO"]
null
Java 17
standard input
[ "implementation" ]
6c137a74b36dede61037cb3b05167329
The first line of the input contains an integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The first line of each test case contains an integer $$$n$$$ $$$(1 \leq n \leq 10)$$$ — the length of string $$$s$$$. The second line of each test case contains a string $$$s$$$ consisting of only uppercase or lowercase Latin characters.
800
For each test case, output "YES" (without quotes) if $$$s$$$ satisfies the condition, and "NO" (without quotes) otherwise. You can output the answer in any case (for example, the strings "yEs", "yes", "Yes" and "YES" will be recognized as a positive answer).
standard output
PASSED
a219e548638bc0d8e13d9ac017ff967f
train_109.jsonl
1661871000
Timur likes his name. As a spelling of his name, he allows any permutation of the letters of the name. For example, the following strings are valid spellings of his name: Timur, miurT, Trumi, mriTu. Note that the correct spelling must have uppercased T and lowercased other letters.Today he wrote string $$$s$$$ of length $$$n$$$ consisting only of uppercase or lowercase Latin letters. He asks you to check if $$$s$$$ is the correct spelling of his name.
256 megabytes
import java.io.*; import java.util.*; public class A1722 { public static void main(String[] args) { MyScanner sc = new MyScanner(); out = new PrintWriter(new BufferedOutputStream(System.out)); // Start writing your solution here. ------------------------------------- // char[] timur = {'T', 'i', 'm', 'u', 'r'}; // int sum = 0; // for (int i = 0; i < timur.length; i++) { // l((int)timur[i]); // sum+=(int)timur[i]; // } // l("the sum is ---- "+sum); int m = sc.nextInt(); outer: while (m-- > 0) { int len = sc.nextInt(); String s = sc.next(); if (len != 5) { out.println("NO"); continue; } char[] schar = s.toCharArray(); int outsum = 0; Arrays.sort(schar); if(String.valueOf(schar).equals("Timru")){ out.println("YES"); }else out.println("NO"); // l("sorted array is - "); // l(schar); // for (int i = 0; i < schar.length; i++) { // outsum += (int) schar[i]; // } // if (outsum == 529) { // for (int i = 0; i < schar.length; i++) { // switch (schar[i]) { // case 'T': // break; // case 'i': // break; // case 'm': // break; // case 'u': // break; // case 'r': // break; // default: { // out.println("NO"); // continue outer; // } // } // } // out.println("YES"); // } else // out.println("NO"); } // Stop writing your solution here. ------------------------------------- out.close(); } // -----------PrintWriter for faster output--------------------------------- public static PrintWriter out; // -----------MyScanner class for faster input---------- public static class MyScanner { BufferedReader br; StringTokenizer st; public MyScanner() { br = new BufferedReader(new InputStreamReader(System.in)); } String next() { while (st == null || !st.hasMoreElements()) { try { st = new StringTokenizer(br.readLine()); } catch (IOException e) { e.printStackTrace(); } } return st.nextToken(); } int nextInt() { return Integer.parseInt(next()); } long nextLong() { return Long.parseLong(next()); } double nextDouble() { return Double.parseDouble(next()); } String nextLine() { String str = ""; try { str = br.readLine(); } catch (IOException e) { e.printStackTrace(); } return str; } } public static void l(Object... o) { String s = ""; for (Object oo : o) { if (oo instanceof int[]) { s += Arrays.toString((int[]) oo) + " "; continue; } if (oo instanceof double[]) { s += Arrays.toString((double[]) oo) + " "; continue; } if (oo instanceof boolean[]) { s += Arrays.toString((boolean[]) oo) + " "; continue; } if (oo instanceof char[]) { s += Arrays.toString((char[]) oo) + " "; continue; } if (oo instanceof long[]) { s += Arrays.toString((long[]) oo) + " "; continue; } if (oo instanceof String[]) { s += Arrays.toString((String[]) oo) + " "; continue; } if (oo instanceof Object[]) { s += Arrays.deepToString((Object[]) oo) + " "; continue; } s += (oo.toString()) + " "; } System.out.println(s); } // -------------------------------------------------------- }
Java
["10\n\n5\n\nTimur\n\n5\n\nmiurT\n\n5\n\nTrumi\n\n5\n\nmriTu\n\n5\n\ntimur\n\n4\n\nTimr\n\n6\n\nTimuur\n\n10\n\ncodeforces\n\n10\n\nTimurTimur\n\n5\n\nTIMUR"]
1 second
["YES\nYES\nYES\nYES\nNO\nNO\nNO\nNO\nNO\nNO"]
null
Java 17
standard input
[ "implementation" ]
6c137a74b36dede61037cb3b05167329
The first line of the input contains an integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The first line of each test case contains an integer $$$n$$$ $$$(1 \leq n \leq 10)$$$ — the length of string $$$s$$$. The second line of each test case contains a string $$$s$$$ consisting of only uppercase or lowercase Latin characters.
800
For each test case, output "YES" (without quotes) if $$$s$$$ satisfies the condition, and "NO" (without quotes) otherwise. You can output the answer in any case (for example, the strings "yEs", "yes", "Yes" and "YES" will be recognized as a positive answer).
standard output
PASSED
f7490144d6f4631649024fec93d8f5fa
train_109.jsonl
1661871000
Timur likes his name. As a spelling of his name, he allows any permutation of the letters of the name. For example, the following strings are valid spellings of his name: Timur, miurT, Trumi, mriTu. Note that the correct spelling must have uppercased T and lowercased other letters.Today he wrote string $$$s$$$ of length $$$n$$$ consisting only of uppercase or lowercase Latin letters. He asks you to check if $$$s$$$ is the correct spelling of his name.
256 megabytes
import java.util.Scanner; import java.util.Vector; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = Integer.parseInt(sc.nextLine()); String output = ""; for (int i = 0; i < n; i++) { Vector v = new Vector(); v.add(Integer.parseInt(sc.nextLine())); v.add(sc.nextLine()); if (!v.get(0).toString().equals("5")) { output += "NO\n"; continue; } if (v.get(1).toString().contains("T") && v.get(1).toString().contains("i") && v.get(1).toString().contains("m") && v.get(1).toString().contains("u") && v.get(1).toString().contains("r")) { output += "YES\n"; } else { output += "NO\n"; } } System.out.println(output); } }
Java
["10\n\n5\n\nTimur\n\n5\n\nmiurT\n\n5\n\nTrumi\n\n5\n\nmriTu\n\n5\n\ntimur\n\n4\n\nTimr\n\n6\n\nTimuur\n\n10\n\ncodeforces\n\n10\n\nTimurTimur\n\n5\n\nTIMUR"]
1 second
["YES\nYES\nYES\nYES\nNO\nNO\nNO\nNO\nNO\nNO"]
null
Java 17
standard input
[ "implementation" ]
6c137a74b36dede61037cb3b05167329
The first line of the input contains an integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The first line of each test case contains an integer $$$n$$$ $$$(1 \leq n \leq 10)$$$ — the length of string $$$s$$$. The second line of each test case contains a string $$$s$$$ consisting of only uppercase or lowercase Latin characters.
800
For each test case, output "YES" (without quotes) if $$$s$$$ satisfies the condition, and "NO" (without quotes) otherwise. You can output the answer in any case (for example, the strings "yEs", "yes", "Yes" and "YES" will be recognized as a positive answer).
standard output
PASSED
d4f978a575ee69b516ca674b1149e970
train_109.jsonl
1661871000
Timur likes his name. As a spelling of his name, he allows any permutation of the letters of the name. For example, the following strings are valid spellings of his name: Timur, miurT, Trumi, mriTu. Note that the correct spelling must have uppercased T and lowercased other letters.Today he wrote string $$$s$$$ of length $$$n$$$ consisting only of uppercase or lowercase Latin letters. He asks you to check if $$$s$$$ is the correct spelling of his name.
256 megabytes
import java.util.Arrays; import java.util.Scanner; /** * @Author Create by jiaxiaozheng * @Date 2022/9/1 */ public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int n = scanner.nextInt(); byte[] target = "Timur".getBytes(); Arrays.sort(target); for (int i = 0; i < n; i++) { scanner.nextInt(); String s=scanner.next(); byte[] bytes = s.getBytes(); Arrays.sort(bytes); System.out.println(Arrays.equals(bytes,target) ? "YES" : "NO"); } } }
Java
["10\n\n5\n\nTimur\n\n5\n\nmiurT\n\n5\n\nTrumi\n\n5\n\nmriTu\n\n5\n\ntimur\n\n4\n\nTimr\n\n6\n\nTimuur\n\n10\n\ncodeforces\n\n10\n\nTimurTimur\n\n5\n\nTIMUR"]
1 second
["YES\nYES\nYES\nYES\nNO\nNO\nNO\nNO\nNO\nNO"]
null
Java 17
standard input
[ "implementation" ]
6c137a74b36dede61037cb3b05167329
The first line of the input contains an integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The first line of each test case contains an integer $$$n$$$ $$$(1 \leq n \leq 10)$$$ — the length of string $$$s$$$. The second line of each test case contains a string $$$s$$$ consisting of only uppercase or lowercase Latin characters.
800
For each test case, output "YES" (without quotes) if $$$s$$$ satisfies the condition, and "NO" (without quotes) otherwise. You can output the answer in any case (for example, the strings "yEs", "yes", "Yes" and "YES" will be recognized as a positive answer).
standard output
PASSED
11d9f0ebd9487c71fbbe4b5297595041
train_109.jsonl
1661871000
Timur likes his name. As a spelling of his name, he allows any permutation of the letters of the name. For example, the following strings are valid spellings of his name: Timur, miurT, Trumi, mriTu. Note that the correct spelling must have uppercased T and lowercased other letters.Today he wrote string $$$s$$$ of length $$$n$$$ consisting only of uppercase or lowercase Latin letters. He asks you to check if $$$s$$$ is the correct spelling of his name.
256 megabytes
import java.io.*; import java.util.*; public class Timur { public static void main(String[] args) throws Exception { BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); int tests = Integer.parseInt(reader.readLine()); for (int i = 0; i < tests; i++) { int n = Integer.parseInt(reader.readLine()); String s = reader.readLine(); Set<Character> set = new HashSet<>(); HashMap<Character, Integer> l = new HashMap<>(); if (n != 5) { System.out.println("NO"); continue; } set.add('T'); set.add('i'); set.add('m'); set.add('u'); set.add('r'); l.put('T', 0); l.put('i', 0); l.put('m', 0); l.put('u', 0); l.put('r', 0); boolean bad = false; for (int j = 0; j < 5; j++) { if (!set.contains(s.charAt(j))) { System.out.println("NO"); bad = true; break; } if (l.get(s.charAt(j)) > 0) { System.out.println("NO"); bad = true; break; } l.put(s.charAt(j), l.get(s.charAt(j))+1); } if (!bad) System.out.println("YES"); } } }
Java
["10\n\n5\n\nTimur\n\n5\n\nmiurT\n\n5\n\nTrumi\n\n5\n\nmriTu\n\n5\n\ntimur\n\n4\n\nTimr\n\n6\n\nTimuur\n\n10\n\ncodeforces\n\n10\n\nTimurTimur\n\n5\n\nTIMUR"]
1 second
["YES\nYES\nYES\nYES\nNO\nNO\nNO\nNO\nNO\nNO"]
null
Java 17
standard input
[ "implementation" ]
6c137a74b36dede61037cb3b05167329
The first line of the input contains an integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The first line of each test case contains an integer $$$n$$$ $$$(1 \leq n \leq 10)$$$ — the length of string $$$s$$$. The second line of each test case contains a string $$$s$$$ consisting of only uppercase or lowercase Latin characters.
800
For each test case, output "YES" (without quotes) if $$$s$$$ satisfies the condition, and "NO" (without quotes) otherwise. You can output the answer in any case (for example, the strings "yEs", "yes", "Yes" and "YES" will be recognized as a positive answer).
standard output
PASSED
7a6d23a2ff670fe050e2190f60aae28f
train_109.jsonl
1661871000
Timur likes his name. As a spelling of his name, he allows any permutation of the letters of the name. For example, the following strings are valid spellings of his name: Timur, miurT, Trumi, mriTu. Note that the correct spelling must have uppercased T and lowercased other letters.Today he wrote string $$$s$$$ of length $$$n$$$ consisting only of uppercase or lowercase Latin letters. He asks you to check if $$$s$$$ is the correct spelling of his name.
256 megabytes
import java.util.*; public class Solution { public static void main(String[] args) { Scanner in = new Scanner(System.in); int t = in.nextInt(); for (int i = 0; i < t; i++) { int n = in.nextInt(); String name = "Timur"; char[] arr = "Timur".toCharArray(); char[] arr2 = in.next().toCharArray(); Arrays.sort(arr); Arrays.sort(arr2); String t1 = String.valueOf(arr); String t2 = String.valueOf(arr2); if(t1.equals(t2)) { System.out.println("YES"); } else { System.out.println("NO"); } } } }
Java
["10\n\n5\n\nTimur\n\n5\n\nmiurT\n\n5\n\nTrumi\n\n5\n\nmriTu\n\n5\n\ntimur\n\n4\n\nTimr\n\n6\n\nTimuur\n\n10\n\ncodeforces\n\n10\n\nTimurTimur\n\n5\n\nTIMUR"]
1 second
["YES\nYES\nYES\nYES\nNO\nNO\nNO\nNO\nNO\nNO"]
null
Java 17
standard input
[ "implementation" ]
6c137a74b36dede61037cb3b05167329
The first line of the input contains an integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The first line of each test case contains an integer $$$n$$$ $$$(1 \leq n \leq 10)$$$ — the length of string $$$s$$$. The second line of each test case contains a string $$$s$$$ consisting of only uppercase or lowercase Latin characters.
800
For each test case, output "YES" (without quotes) if $$$s$$$ satisfies the condition, and "NO" (without quotes) otherwise. You can output the answer in any case (for example, the strings "yEs", "yes", "Yes" and "YES" will be recognized as a positive answer).
standard output
PASSED
f76e05212df45a9e1190f8dc14e3b624
train_109.jsonl
1661871000
Timur likes his name. As a spelling of his name, he allows any permutation of the letters of the name. For example, the following strings are valid spellings of his name: Timur, miurT, Trumi, mriTu. Note that the correct spelling must have uppercased T and lowercased other letters.Today he wrote string $$$s$$$ of length $$$n$$$ consisting only of uppercase or lowercase Latin letters. He asks you to check if $$$s$$$ is the correct spelling of his name.
256 megabytes
import java.util.*; public class Codeforces { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int tc = sc.nextInt(); while (tc-- > 0) { int n = sc.nextInt(); String s = sc.next(); Set<Character> set = new HashSet<>(); set.add('T'); set.add('i'); set.add('m'); set.add('u'); set.add('r'); boolean flag = true; for (int i = 0; i < s.length(); i++) { char c = s.charAt(i); if (!set.contains(c)) { flag =false; break; } else set.remove(c); } if(flag && set.isEmpty()) System.out.println("YES"); else System.out.println("NO"); } } }
Java
["10\n\n5\n\nTimur\n\n5\n\nmiurT\n\n5\n\nTrumi\n\n5\n\nmriTu\n\n5\n\ntimur\n\n4\n\nTimr\n\n6\n\nTimuur\n\n10\n\ncodeforces\n\n10\n\nTimurTimur\n\n5\n\nTIMUR"]
1 second
["YES\nYES\nYES\nYES\nNO\nNO\nNO\nNO\nNO\nNO"]
null
Java 17
standard input
[ "implementation" ]
6c137a74b36dede61037cb3b05167329
The first line of the input contains an integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The first line of each test case contains an integer $$$n$$$ $$$(1 \leq n \leq 10)$$$ — the length of string $$$s$$$. The second line of each test case contains a string $$$s$$$ consisting of only uppercase or lowercase Latin characters.
800
For each test case, output "YES" (without quotes) if $$$s$$$ satisfies the condition, and "NO" (without quotes) otherwise. You can output the answer in any case (for example, the strings "yEs", "yes", "Yes" and "YES" will be recognized as a positive answer).
standard output
PASSED
b2569b8a6f1649e653d6a4690ef7a007
train_109.jsonl
1661871000
Timur likes his name. As a spelling of his name, he allows any permutation of the letters of the name. For example, the following strings are valid spellings of his name: Timur, miurT, Trumi, mriTu. Note that the correct spelling must have uppercased T and lowercased other letters.Today he wrote string $$$s$$$ of length $$$n$$$ consisting only of uppercase or lowercase Latin letters. He asks you to check if $$$s$$$ is the correct spelling of his name.
256 megabytes
import java.util.*; public class Solution { public static boolean check(char c) { return c=='T'||c=='i'||c=='m'||c=='u'||c=='r'; } public static void main(String[] args) { Scanner sc=new Scanner(System.in); int t= sc.nextInt(); while (t-->0) { boolean flag=false; int n= sc.nextInt(); sc.nextLine(); String in=sc.nextLine(); if(n == 5) { int count=0; HashSet<Character> set=new HashSet<>(); int i=0; while(i<5) { char c=in.charAt(i); if( !set.contains(c) && check(c)) {count++;set.add(c);} else {break;} i++; } if(count==5) flag=true; } System.out.println(flag?"YES":"NO"); } } }
Java
["10\n\n5\n\nTimur\n\n5\n\nmiurT\n\n5\n\nTrumi\n\n5\n\nmriTu\n\n5\n\ntimur\n\n4\n\nTimr\n\n6\n\nTimuur\n\n10\n\ncodeforces\n\n10\n\nTimurTimur\n\n5\n\nTIMUR"]
1 second
["YES\nYES\nYES\nYES\nNO\nNO\nNO\nNO\nNO\nNO"]
null
Java 17
standard input
[ "implementation" ]
6c137a74b36dede61037cb3b05167329
The first line of the input contains an integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The first line of each test case contains an integer $$$n$$$ $$$(1 \leq n \leq 10)$$$ — the length of string $$$s$$$. The second line of each test case contains a string $$$s$$$ consisting of only uppercase or lowercase Latin characters.
800
For each test case, output "YES" (without quotes) if $$$s$$$ satisfies the condition, and "NO" (without quotes) otherwise. You can output the answer in any case (for example, the strings "yEs", "yes", "Yes" and "YES" will be recognized as a positive answer).
standard output
PASSED
da9a7b854b0aae0dbe07798d74071791
train_109.jsonl
1661871000
Timur likes his name. As a spelling of his name, he allows any permutation of the letters of the name. For example, the following strings are valid spellings of his name: Timur, miurT, Trumi, mriTu. Note that the correct spelling must have uppercased T and lowercased other letters.Today he wrote string $$$s$$$ of length $$$n$$$ consisting only of uppercase or lowercase Latin letters. He asks you to check if $$$s$$$ is the correct spelling of his name.
256 megabytes
import java.util.*; public class Solution { public static String Solver(String s, int n) { String compare = "Timur"; if(n != compare.length()) return "NO"; char[] ch1 = compare.toCharArray(), ch2 = s.toCharArray(); Arrays.sort(ch1); Arrays.sort(ch2); for(int i=0; i<ch1.length; i++) { if(ch1[i] != ch2[i]) return "NO"; } return "YES"; } public static void main(String[] args) { // TODO Auto-generated method stub Scanner sc = new Scanner(System.in); int t = sc.nextInt(); for(int i = 0; i < t; i++) { int size = sc.nextInt(); String s = sc.next(); System.out.println(Solver(s, size)); } sc.close(); } }
Java
["10\n\n5\n\nTimur\n\n5\n\nmiurT\n\n5\n\nTrumi\n\n5\n\nmriTu\n\n5\n\ntimur\n\n4\n\nTimr\n\n6\n\nTimuur\n\n10\n\ncodeforces\n\n10\n\nTimurTimur\n\n5\n\nTIMUR"]
1 second
["YES\nYES\nYES\nYES\nNO\nNO\nNO\nNO\nNO\nNO"]
null
Java 17
standard input
[ "implementation" ]
6c137a74b36dede61037cb3b05167329
The first line of the input contains an integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The first line of each test case contains an integer $$$n$$$ $$$(1 \leq n \leq 10)$$$ — the length of string $$$s$$$. The second line of each test case contains a string $$$s$$$ consisting of only uppercase or lowercase Latin characters.
800
For each test case, output "YES" (without quotes) if $$$s$$$ satisfies the condition, and "NO" (without quotes) otherwise. You can output the answer in any case (for example, the strings "yEs", "yes", "Yes" and "YES" will be recognized as a positive answer).
standard output
PASSED
db6741e47c7f343972baa4fd185c84bc
train_109.jsonl
1661871000
Timur likes his name. As a spelling of his name, he allows any permutation of the letters of the name. For example, the following strings are valid spellings of his name: Timur, miurT, Trumi, mriTu. Note that the correct spelling must have uppercased T and lowercased other letters.Today he wrote string $$$s$$$ of length $$$n$$$ consisting only of uppercase or lowercase Latin letters. He asks you to check if $$$s$$$ is the correct spelling of his name.
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.HashMap; import java.util.HashSet; public class Main { public static void main(String[] args) throws IOException { BufferedReader input = new BufferedReader(new InputStreamReader(System.in)); int numberOfCases = Integer.parseInt(input.readLine()); HashMap<Character, Integer> freq = new HashMap<>(); for (int i = 0; i < numberOfCases; i++) { input.readLine(); String inp = input.readLine(); if (inp.length() == 5) { for (char c : inp.toCharArray()) { freq.put(c, freq.getOrDefault(c, 0) + 1); } boolean valid = true; for (char c : "Timur".toCharArray()) { if (freq.getOrDefault(c, 0) != 1) valid = false; freq.remove(c); } if (valid & freq.isEmpty()) System.out.println("YES"); else System.out.println("NO"); } else { System.out.println("NO"); } freq.clear(); } } }
Java
["10\n\n5\n\nTimur\n\n5\n\nmiurT\n\n5\n\nTrumi\n\n5\n\nmriTu\n\n5\n\ntimur\n\n4\n\nTimr\n\n6\n\nTimuur\n\n10\n\ncodeforces\n\n10\n\nTimurTimur\n\n5\n\nTIMUR"]
1 second
["YES\nYES\nYES\nYES\nNO\nNO\nNO\nNO\nNO\nNO"]
null
Java 17
standard input
[ "implementation" ]
6c137a74b36dede61037cb3b05167329
The first line of the input contains an integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The first line of each test case contains an integer $$$n$$$ $$$(1 \leq n \leq 10)$$$ — the length of string $$$s$$$. The second line of each test case contains a string $$$s$$$ consisting of only uppercase or lowercase Latin characters.
800
For each test case, output "YES" (without quotes) if $$$s$$$ satisfies the condition, and "NO" (without quotes) otherwise. You can output the answer in any case (for example, the strings "yEs", "yes", "Yes" and "YES" will be recognized as a positive answer).
standard output
PASSED
e5b4c48258eb83c9165c4313a67bcc84
train_109.jsonl
1661871000
Timur likes his name. As a spelling of his name, he allows any permutation of the letters of the name. For example, the following strings are valid spellings of his name: Timur, miurT, Trumi, mriTu. Note that the correct spelling must have uppercased T and lowercased other letters.Today he wrote string $$$s$$$ of length $$$n$$$ consisting only of uppercase or lowercase Latin letters. He asks you to check if $$$s$$$ is the correct spelling of his name.
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Arrays; public class Main817A { public static void main(String[] args) throws IOException { BufferedReader input = new BufferedReader(new InputStreamReader(System.in)); int numberOfCases = Integer.parseInt(input.readLine()); for (int i = 0; i < numberOfCases; i++) { input.readLine(); char[] chars = input.readLine().toCharArray(); Arrays.sort(chars); if ("Timru".equals(new String(chars))){ System.out.println("YES"); }else{ System.out.println("NO"); } } } }
Java
["10\n\n5\n\nTimur\n\n5\n\nmiurT\n\n5\n\nTrumi\n\n5\n\nmriTu\n\n5\n\ntimur\n\n4\n\nTimr\n\n6\n\nTimuur\n\n10\n\ncodeforces\n\n10\n\nTimurTimur\n\n5\n\nTIMUR"]
1 second
["YES\nYES\nYES\nYES\nNO\nNO\nNO\nNO\nNO\nNO"]
null
Java 17
standard input
[ "implementation" ]
6c137a74b36dede61037cb3b05167329
The first line of the input contains an integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The first line of each test case contains an integer $$$n$$$ $$$(1 \leq n \leq 10)$$$ — the length of string $$$s$$$. The second line of each test case contains a string $$$s$$$ consisting of only uppercase or lowercase Latin characters.
800
For each test case, output "YES" (without quotes) if $$$s$$$ satisfies the condition, and "NO" (without quotes) otherwise. You can output the answer in any case (for example, the strings "yEs", "yes", "Yes" and "YES" will be recognized as a positive answer).
standard output
PASSED
6301bc5110062f4c8b98ecde87a44b01
train_109.jsonl
1661871000
Timur likes his name. As a spelling of his name, he allows any permutation of the letters of the name. For example, the following strings are valid spellings of his name: Timur, miurT, Trumi, mriTu. Note that the correct spelling must have uppercased T and lowercased other letters.Today he wrote string $$$s$$$ of length $$$n$$$ consisting only of uppercase or lowercase Latin letters. He asks you to check if $$$s$$$ is the correct spelling of his name.
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.HashMap; import java.util.HashSet; public class Main { public static void main(String[] args) throws IOException { BufferedReader input = new BufferedReader(new InputStreamReader(System.in)); int numberOfCases = Integer.parseInt(input.readLine()); HashSet<Character> characters = new HashSet<>(); HashMap<Character, Integer> freq = new HashMap<>(); for (int i = 0; i < numberOfCases; i++) { input.readLine(); String inp = input.readLine(); if (inp.length() == 5) { for (char c : inp.toCharArray()) { freq.put(c, freq.getOrDefault(c, 0) + 1); } boolean valid = true; for (char c : "Timur".toCharArray()) { if (freq.getOrDefault(c, 0) != 1) valid = false; freq.remove(c); } if (valid & freq.isEmpty()) System.out.println("YES"); else System.out.println("NO"); } else { System.out.println("NO"); } freq.clear(); } } }
Java
["10\n\n5\n\nTimur\n\n5\n\nmiurT\n\n5\n\nTrumi\n\n5\n\nmriTu\n\n5\n\ntimur\n\n4\n\nTimr\n\n6\n\nTimuur\n\n10\n\ncodeforces\n\n10\n\nTimurTimur\n\n5\n\nTIMUR"]
1 second
["YES\nYES\nYES\nYES\nNO\nNO\nNO\nNO\nNO\nNO"]
null
Java 17
standard input
[ "implementation" ]
6c137a74b36dede61037cb3b05167329
The first line of the input contains an integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The first line of each test case contains an integer $$$n$$$ $$$(1 \leq n \leq 10)$$$ — the length of string $$$s$$$. The second line of each test case contains a string $$$s$$$ consisting of only uppercase or lowercase Latin characters.
800
For each test case, output "YES" (without quotes) if $$$s$$$ satisfies the condition, and "NO" (without quotes) otherwise. You can output the answer in any case (for example, the strings "yEs", "yes", "Yes" and "YES" will be recognized as a positive answer).
standard output
PASSED
0ee97e23915ea01f7cab37422a4eeb3a
train_109.jsonl
1661871000
Timur likes his name. As a spelling of his name, he allows any permutation of the letters of the name. For example, the following strings are valid spellings of his name: Timur, miurT, Trumi, mriTu. Note that the correct spelling must have uppercased T and lowercased other letters.Today he wrote string $$$s$$$ of length $$$n$$$ consisting only of uppercase or lowercase Latin letters. He asks you to check if $$$s$$$ is the correct spelling of his name.
256 megabytes
//package com.company; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.Scanner; public class Demo { public static void main(String[] args) { Scanner in = new Scanner(System.in); int t = in.nextInt(); while(t-- > 0) { int n = in.nextInt(); in.nextLine(); String name = in.nextLine(); int count = 0; String s = "Timur"; if(n == 5) { for (int i = 0; i < s.length(); i++) { if (find(name, s.charAt(i))) { count++; } } if (count == 5) { System.out.println("Yes"); } else { System.out.println("No"); } }else{ System.out.println("No"); } } } public static boolean find(String name , char c){ for (int i = 0; i < name.length(); i++) { if(name.charAt(i) == c){ return true; } } return false; } }
Java
["10\n\n5\n\nTimur\n\n5\n\nmiurT\n\n5\n\nTrumi\n\n5\n\nmriTu\n\n5\n\ntimur\n\n4\n\nTimr\n\n6\n\nTimuur\n\n10\n\ncodeforces\n\n10\n\nTimurTimur\n\n5\n\nTIMUR"]
1 second
["YES\nYES\nYES\nYES\nNO\nNO\nNO\nNO\nNO\nNO"]
null
Java 17
standard input
[ "implementation" ]
6c137a74b36dede61037cb3b05167329
The first line of the input contains an integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The first line of each test case contains an integer $$$n$$$ $$$(1 \leq n \leq 10)$$$ — the length of string $$$s$$$. The second line of each test case contains a string $$$s$$$ consisting of only uppercase or lowercase Latin characters.
800
For each test case, output "YES" (without quotes) if $$$s$$$ satisfies the condition, and "NO" (without quotes) otherwise. You can output the answer in any case (for example, the strings "yEs", "yes", "Yes" and "YES" will be recognized as a positive answer).
standard output
PASSED
64dab77815b9094ca40277fdc425d480
train_109.jsonl
1661871000
Timur likes his name. As a spelling of his name, he allows any permutation of the letters of the name. For example, the following strings are valid spellings of his name: Timur, miurT, Trumi, mriTu. Note that the correct spelling must have uppercased T and lowercased other letters.Today he wrote string $$$s$$$ of length $$$n$$$ consisting only of uppercase or lowercase Latin letters. He asks you to check if $$$s$$$ is the correct spelling of his name.
256 megabytes
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner input = new Scanner(System.in); int t = input.nextInt(); int n = 0; String rta = "YES"; String s = ""; for (int i = 0; i < t; i++) { n = input.nextInt(); if (n == 5) { s = input.next(); if (!s.contains("T") || !s.contains("i") || !s.contains("m") || !s.contains("u") || !s.contains("r")) rta = "NO"; } else { s = input.next(); rta = "NO"; } System.out.println(rta); rta = "YES"; } } }
Java
["10\n\n5\n\nTimur\n\n5\n\nmiurT\n\n5\n\nTrumi\n\n5\n\nmriTu\n\n5\n\ntimur\n\n4\n\nTimr\n\n6\n\nTimuur\n\n10\n\ncodeforces\n\n10\n\nTimurTimur\n\n5\n\nTIMUR"]
1 second
["YES\nYES\nYES\nYES\nNO\nNO\nNO\nNO\nNO\nNO"]
null
Java 17
standard input
[ "implementation" ]
6c137a74b36dede61037cb3b05167329
The first line of the input contains an integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The first line of each test case contains an integer $$$n$$$ $$$(1 \leq n \leq 10)$$$ — the length of string $$$s$$$. The second line of each test case contains a string $$$s$$$ consisting of only uppercase or lowercase Latin characters.
800
For each test case, output "YES" (without quotes) if $$$s$$$ satisfies the condition, and "NO" (without quotes) otherwise. You can output the answer in any case (for example, the strings "yEs", "yes", "Yes" and "YES" will be recognized as a positive answer).
standard output
PASSED
7023802ddd2dd0bf463400b1a9e96f4b
train_109.jsonl
1661871000
Timur likes his name. As a spelling of his name, he allows any permutation of the letters of the name. For example, the following strings are valid spellings of his name: Timur, miurT, Trumi, mriTu. Note that the correct spelling must have uppercased T and lowercased other letters.Today he wrote string $$$s$$$ of length $$$n$$$ consisting only of uppercase or lowercase Latin letters. He asks you to check if $$$s$$$ is the correct spelling of his name.
256 megabytes
import java.util.*; public class Main { public static boolean check(String input,String str){ if(input.length()!=str.length()){ return false; } int arr1[]=new int[27]; int arr2[]=new int[27]; for(int i=0;i<str.length();i++){ int val=str.charAt(i)-'a'; if(str.charAt(i)!='T' && val<0){ return false; } } for(int i=0;i<str.length();i++){ if(str.charAt(i)=='T'){ arr1[0]++; continue; } arr1[str.charAt(i)-'a'+1]++; } for(int i=0;i<input.length();i++){ if(input.charAt(i)=='T'){ arr2[0]++; continue; } arr2[input.charAt(i)-'a'+1]++; } for(int i=0;i<27;i++){ if(arr1[i]!=arr2[i]){ return false; } } return true; } public static void main(String args[]) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); while(n>0){ int x=sc.nextInt(); sc.nextLine(); String s= sc.nextLine(); if(check("Timur",s)){ System.out.println("YES"); } else { System.out.println("No"); } n--; } } }
Java
["10\n\n5\n\nTimur\n\n5\n\nmiurT\n\n5\n\nTrumi\n\n5\n\nmriTu\n\n5\n\ntimur\n\n4\n\nTimr\n\n6\n\nTimuur\n\n10\n\ncodeforces\n\n10\n\nTimurTimur\n\n5\n\nTIMUR"]
1 second
["YES\nYES\nYES\nYES\nNO\nNO\nNO\nNO\nNO\nNO"]
null
Java 17
standard input
[ "implementation" ]
6c137a74b36dede61037cb3b05167329
The first line of the input contains an integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The first line of each test case contains an integer $$$n$$$ $$$(1 \leq n \leq 10)$$$ — the length of string $$$s$$$. The second line of each test case contains a string $$$s$$$ consisting of only uppercase or lowercase Latin characters.
800
For each test case, output "YES" (without quotes) if $$$s$$$ satisfies the condition, and "NO" (without quotes) otherwise. You can output the answer in any case (for example, the strings "yEs", "yes", "Yes" and "YES" will be recognized as a positive answer).
standard output
PASSED
0c073b39492cc76c082d002fea225710
train_109.jsonl
1661871000
Timur likes his name. As a spelling of his name, he allows any permutation of the letters of the name. For example, the following strings are valid spellings of his name: Timur, miurT, Trumi, mriTu. Note that the correct spelling must have uppercased T and lowercased other letters.Today he wrote string $$$s$$$ of length $$$n$$$ consisting only of uppercase or lowercase Latin letters. He asks you to check if $$$s$$$ is the correct spelling of his name.
256 megabytes
import java.util.HashMap; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); int Times = in.nextInt(); while(Times-- > 0){ int length = in.nextInt(); String str = in.next(); HashMap<Character,Integer> hMap = new HashMap<>(); hMap.put('T',1); hMap.put('i',1); hMap.put('m',1); hMap.put('u',1); hMap.put('r',1); if(length != 5){ System.out.println("NO"); }else{ int flag = -1; for (int i = 0;i < str.length();i++){ if(!hMap.containsKey(str.charAt(i))) { flag = 1; break; }else{ int count = hMap.get(str.charAt(i)); hMap.put(str.charAt(i),count-1); } if(hMap.containsValue(-1)){ flag = 1; break; } } if(flag == 1) System.out.println("NO"); else System.out.println("YES"); } } } }
Java
["10\n\n5\n\nTimur\n\n5\n\nmiurT\n\n5\n\nTrumi\n\n5\n\nmriTu\n\n5\n\ntimur\n\n4\n\nTimr\n\n6\n\nTimuur\n\n10\n\ncodeforces\n\n10\n\nTimurTimur\n\n5\n\nTIMUR"]
1 second
["YES\nYES\nYES\nYES\nNO\nNO\nNO\nNO\nNO\nNO"]
null
Java 17
standard input
[ "implementation" ]
6c137a74b36dede61037cb3b05167329
The first line of the input contains an integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The first line of each test case contains an integer $$$n$$$ $$$(1 \leq n \leq 10)$$$ — the length of string $$$s$$$. The second line of each test case contains a string $$$s$$$ consisting of only uppercase or lowercase Latin characters.
800
For each test case, output "YES" (without quotes) if $$$s$$$ satisfies the condition, and "NO" (without quotes) otherwise. You can output the answer in any case (for example, the strings "yEs", "yes", "Yes" and "YES" will be recognized as a positive answer).
standard output
PASSED
739fa0b7c8ad8af85a2f258fed208bc3
train_109.jsonl
1661871000
Timur likes his name. As a spelling of his name, he allows any permutation of the letters of the name. For example, the following strings are valid spellings of his name: Timur, miurT, Trumi, mriTu. Note that the correct spelling must have uppercased T and lowercased other letters.Today he wrote string $$$s$$$ of length $$$n$$$ consisting only of uppercase or lowercase Latin letters. He asks you to check if $$$s$$$ is the correct spelling of his name.
256 megabytes
import java.util.*; public class Spell_Check { public static void main(String[] args) { Scanner input=new Scanner(System.in); int n=input.nextInt(); for (int i = 0; i < n; i++) { int t=input.nextInt(),x=0; String s=input.next(),name="Timur"; if(t==5){ for (int j = 0; j <t; j++) for (int k = 0; k <name.length(); k++) if(s.charAt(j)==name.charAt(k)){ x++; name=name.substring(0, k)+name.substring(k+1); break; } } else x=0; System.out.println((x==5)?"YES":"NO"); } } }
Java
["10\n\n5\n\nTimur\n\n5\n\nmiurT\n\n5\n\nTrumi\n\n5\n\nmriTu\n\n5\n\ntimur\n\n4\n\nTimr\n\n6\n\nTimuur\n\n10\n\ncodeforces\n\n10\n\nTimurTimur\n\n5\n\nTIMUR"]
1 second
["YES\nYES\nYES\nYES\nNO\nNO\nNO\nNO\nNO\nNO"]
null
Java 17
standard input
[ "implementation" ]
6c137a74b36dede61037cb3b05167329
The first line of the input contains an integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The first line of each test case contains an integer $$$n$$$ $$$(1 \leq n \leq 10)$$$ — the length of string $$$s$$$. The second line of each test case contains a string $$$s$$$ consisting of only uppercase or lowercase Latin characters.
800
For each test case, output "YES" (without quotes) if $$$s$$$ satisfies the condition, and "NO" (without quotes) otherwise. You can output the answer in any case (for example, the strings "yEs", "yes", "Yes" and "YES" will be recognized as a positive answer).
standard output
PASSED
76b6c877da7385dd712ecc4c3fb234d7
train_109.jsonl
1661871000
Timur likes his name. As a spelling of his name, he allows any permutation of the letters of the name. For example, the following strings are valid spellings of his name: Timur, miurT, Trumi, mriTu. Note that the correct spelling must have uppercased T and lowercased other letters.Today he wrote string $$$s$$$ of length $$$n$$$ consisting only of uppercase or lowercase Latin letters. He asks you to check if $$$s$$$ is the correct spelling of his name.
256 megabytes
import java.util.*; public class SpellCheck { public static void main(String[] args) { Scanner sc = new Scanner(System.in); //System.out.println("Enter the number of test sets"); int n=sc.nextInt(); String[] s=new String[n]; //System.out.println("Enter the Spellings:"); for(int i=0;i<n;i++) { int l=sc.nextInt(); s[i]=sc.next(); } for(int i=0;i<n;i++) { String x=s[i]; char []arr = x.toCharArray(); Arrays.sort(arr); if(String.valueOf(arr).equals("Timru")) { System.out.println("YES"); } else { System.out.println("NO"); } } } }
Java
["10\n\n5\n\nTimur\n\n5\n\nmiurT\n\n5\n\nTrumi\n\n5\n\nmriTu\n\n5\n\ntimur\n\n4\n\nTimr\n\n6\n\nTimuur\n\n10\n\ncodeforces\n\n10\n\nTimurTimur\n\n5\n\nTIMUR"]
1 second
["YES\nYES\nYES\nYES\nNO\nNO\nNO\nNO\nNO\nNO"]
null
Java 17
standard input
[ "implementation" ]
6c137a74b36dede61037cb3b05167329
The first line of the input contains an integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The first line of each test case contains an integer $$$n$$$ $$$(1 \leq n \leq 10)$$$ — the length of string $$$s$$$. The second line of each test case contains a string $$$s$$$ consisting of only uppercase or lowercase Latin characters.
800
For each test case, output "YES" (without quotes) if $$$s$$$ satisfies the condition, and "NO" (without quotes) otherwise. You can output the answer in any case (for example, the strings "yEs", "yes", "Yes" and "YES" will be recognized as a positive answer).
standard output
PASSED
f8ced7f2f7a10d25cf5704bf20676f7a
train_109.jsonl
1661871000
Timur likes his name. As a spelling of his name, he allows any permutation of the letters of the name. For example, the following strings are valid spellings of his name: Timur, miurT, Trumi, mriTu. Note that the correct spelling must have uppercased T and lowercased other letters.Today he wrote string $$$s$$$ of length $$$n$$$ consisting only of uppercase or lowercase Latin letters. He asks you to check if $$$s$$$ is the correct spelling of his name.
256 megabytes
import java.util.*; public class Codeforces { public static void main(String[] args) { Scanner lta = new Scanner(System.in); int t = lta.nextInt(); while (t-- >0) { int n = lta.nextInt(); String s = lta.next(); ArrayList<Character> alist = new ArrayList<>(); if (n == 5) { for (int i = 0; i < s.length(); i++) { if (!alist.contains(s.charAt(i))){ alist.add(s.charAt(i)); } } int temp = 0; Collections.sort(alist); if (alist.size() == 5){ if (alist.get(0) != 'T'){ temp = 1; } if (alist.get(1) != 'i'){ temp = 1; } if (alist.get(2) != 'm'){ temp = 1; } if (alist.get(3) != 'r'){ temp = 1; } if (alist.get(4) != 'u'){ temp = 1; } if (temp == 0){ System.out.println("YES"); } else { System.out.println("NO"); } } else { System.out.println("NO"); } } else { System.out.println("NO"); } } } }
Java
["10\n\n5\n\nTimur\n\n5\n\nmiurT\n\n5\n\nTrumi\n\n5\n\nmriTu\n\n5\n\ntimur\n\n4\n\nTimr\n\n6\n\nTimuur\n\n10\n\ncodeforces\n\n10\n\nTimurTimur\n\n5\n\nTIMUR"]
1 second
["YES\nYES\nYES\nYES\nNO\nNO\nNO\nNO\nNO\nNO"]
null
Java 17
standard input
[ "implementation" ]
6c137a74b36dede61037cb3b05167329
The first line of the input contains an integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The first line of each test case contains an integer $$$n$$$ $$$(1 \leq n \leq 10)$$$ — the length of string $$$s$$$. The second line of each test case contains a string $$$s$$$ consisting of only uppercase or lowercase Latin characters.
800
For each test case, output "YES" (without quotes) if $$$s$$$ satisfies the condition, and "NO" (without quotes) otherwise. You can output the answer in any case (for example, the strings "yEs", "yes", "Yes" and "YES" will be recognized as a positive answer).
standard output
PASSED
e0ac07a4998e8c01bf58302688d7056d
train_109.jsonl
1661871000
Timur likes his name. As a spelling of his name, he allows any permutation of the letters of the name. For example, the following strings are valid spellings of his name: Timur, miurT, Trumi, mriTu. Note that the correct spelling must have uppercased T and lowercased other letters.Today he wrote string $$$s$$$ of length $$$n$$$ consisting only of uppercase or lowercase Latin letters. He asks you to check if $$$s$$$ is the correct spelling of his name.
256 megabytes
import java.util.*; public class ACMP { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int t = scan.nextInt(); char[] arr = {'T', 'i', 'm', 'u', 'r'}; Arrays.sort(arr); a: for(int i = 0; i < t; i++) { int n = scan.nextInt(); String s = scan.next(); if(n == 5) { char[] temp = s.toCharArray(); Arrays.sort(temp); for(int j = 0; j < 5; j++) { if(temp[j] != arr[j]) { System.out.println("NO"); continue a; } } System.out.println("YES"); } else { System.out.println("NO"); } } } }
Java
["10\n\n5\n\nTimur\n\n5\n\nmiurT\n\n5\n\nTrumi\n\n5\n\nmriTu\n\n5\n\ntimur\n\n4\n\nTimr\n\n6\n\nTimuur\n\n10\n\ncodeforces\n\n10\n\nTimurTimur\n\n5\n\nTIMUR"]
1 second
["YES\nYES\nYES\nYES\nNO\nNO\nNO\nNO\nNO\nNO"]
null
Java 17
standard input
[ "implementation" ]
6c137a74b36dede61037cb3b05167329
The first line of the input contains an integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The first line of each test case contains an integer $$$n$$$ $$$(1 \leq n \leq 10)$$$ — the length of string $$$s$$$. The second line of each test case contains a string $$$s$$$ consisting of only uppercase or lowercase Latin characters.
800
For each test case, output "YES" (without quotes) if $$$s$$$ satisfies the condition, and "NO" (without quotes) otherwise. You can output the answer in any case (for example, the strings "yEs", "yes", "Yes" and "YES" will be recognized as a positive answer).
standard output
PASSED
7813da154c59d428568e8a97c6419710
train_109.jsonl
1661871000
Timur likes his name. As a spelling of his name, he allows any permutation of the letters of the name. For example, the following strings are valid spellings of his name: Timur, miurT, Trumi, mriTu. Note that the correct spelling must have uppercased T and lowercased other letters.Today he wrote string $$$s$$$ of length $$$n$$$ consisting only of uppercase or lowercase Latin letters. He asks you to check if $$$s$$$ is the correct spelling of his name.
256 megabytes
import java.util.*; public class SpellCheck { public static void main(String[] args) { Scanner input = new Scanner(System.in); StringBuilder result = new StringBuilder(); int tc = Integer.parseInt(input.nextLine()); HashMap<Character, Integer> map = new HashMap<>(); while (tc --> 0) { int length = Integer.parseInt(input.nextLine()); String chars = input.nextLine(); if (length != 5) { result.append("NO\n"); continue; } map.put('T', 0); map.put('i', 0); map.put('m', 0); map.put('u', 0); map.put('r', 0); boolean found = false; boolean isOne = true; for (Character c : chars.toCharArray()) { Integer a = map.get(c); if (a == null || a != 0) { result.append("NO\n"); found = true; break; } map.put(c, 1); } if (!found) { for (Character c : map.keySet()) { isOne = isOne && map.get(c) == 1; } if (isOne) result.append("YES\n"); } } System.out.println(result.substring(0, result.length() - 1)); } }
Java
["10\n\n5\n\nTimur\n\n5\n\nmiurT\n\n5\n\nTrumi\n\n5\n\nmriTu\n\n5\n\ntimur\n\n4\n\nTimr\n\n6\n\nTimuur\n\n10\n\ncodeforces\n\n10\n\nTimurTimur\n\n5\n\nTIMUR"]
1 second
["YES\nYES\nYES\nYES\nNO\nNO\nNO\nNO\nNO\nNO"]
null
Java 17
standard input
[ "implementation" ]
6c137a74b36dede61037cb3b05167329
The first line of the input contains an integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The first line of each test case contains an integer $$$n$$$ $$$(1 \leq n \leq 10)$$$ — the length of string $$$s$$$. The second line of each test case contains a string $$$s$$$ consisting of only uppercase or lowercase Latin characters.
800
For each test case, output "YES" (without quotes) if $$$s$$$ satisfies the condition, and "NO" (without quotes) otherwise. You can output the answer in any case (for example, the strings "yEs", "yes", "Yes" and "YES" will be recognized as a positive answer).
standard output
PASSED
9b76eaaa7f8a2d50e497df1e4aa1a14d
train_109.jsonl
1661871000
Timur likes his name. As a spelling of his name, he allows any permutation of the letters of the name. For example, the following strings are valid spellings of his name: Timur, miurT, Trumi, mriTu. Note that the correct spelling must have uppercased T and lowercased other letters.Today he wrote string $$$s$$$ of length $$$n$$$ consisting only of uppercase or lowercase Latin letters. He asks you to check if $$$s$$$ is the correct spelling of his name.
256 megabytes
import java.io.IOException; import java.io.InputStreamReader; import java.io.BufferedReader; import java.util.HashMap; public class A { public static void main(final String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); HashMap<Character, Boolean> pre = new HashMap<>(); pre.put('T', false); pre.put('i', false); pre.put('m', false); pre.put('u', false); pre.put('r', false); int t = Integer.parseInt(br.readLine()); while(t-- > 0) { final int n = Integer.parseInt(br.readLine()); final String s = br.readLine(); if(n == 5) { for(char c: s.toCharArray()) { if(pre.containsKey(c)) { pre.put(c, true); } } boolean result = true; for(char k: pre.keySet()) { result = result && pre.get(k); } System.out.println(result ? "YES" : "NO"); pre.put('T', false); pre.put('i', false); pre.put('m', false); pre.put('u', false); pre.put('r', false); } else { System.out.println("NO"); } } } }
Java
["10\n\n5\n\nTimur\n\n5\n\nmiurT\n\n5\n\nTrumi\n\n5\n\nmriTu\n\n5\n\ntimur\n\n4\n\nTimr\n\n6\n\nTimuur\n\n10\n\ncodeforces\n\n10\n\nTimurTimur\n\n5\n\nTIMUR"]
1 second
["YES\nYES\nYES\nYES\nNO\nNO\nNO\nNO\nNO\nNO"]
null
Java 17
standard input
[ "implementation" ]
6c137a74b36dede61037cb3b05167329
The first line of the input contains an integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The first line of each test case contains an integer $$$n$$$ $$$(1 \leq n \leq 10)$$$ — the length of string $$$s$$$. The second line of each test case contains a string $$$s$$$ consisting of only uppercase or lowercase Latin characters.
800
For each test case, output "YES" (without quotes) if $$$s$$$ satisfies the condition, and "NO" (without quotes) otherwise. You can output the answer in any case (for example, the strings "yEs", "yes", "Yes" and "YES" will be recognized as a positive answer).
standard output
PASSED
8ad86f9a7f0853ac152065e1ae6f0204
train_109.jsonl
1661871000
Timur likes his name. As a spelling of his name, he allows any permutation of the letters of the name. For example, the following strings are valid spellings of his name: Timur, miurT, Trumi, mriTu. Note that the correct spelling must have uppercased T and lowercased other letters.Today he wrote string $$$s$$$ of length $$$n$$$ consisting only of uppercase or lowercase Latin letters. He asks you to check if $$$s$$$ is the correct spelling of his name.
256 megabytes
import java.util.*; public class hi { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int t = sc.nextInt(); for(int i=0;i<t;i++) { int n=sc.nextInt(); String s = sc.next(); if(n!=5) { System.out.println("NO"); continue; } boolean flag[] =new boolean[5]; for(int j=0;j<n;j++) { if(s.charAt(j)=='T') { flag[0]= true; break; } } for(int j=0;j<n;j++) { if(s.charAt(j)=='i') { flag[1]= true; break; } } for(int j=0;j<n;j++) { if(s.charAt(j)=='m') { flag[2]= true; break; } } for(int j=0;j<n;j++) { if(s.charAt(j)=='u') { flag[3]= true; break; } } for(int j=0;j<n;j++) { if(s.charAt(j)=='r') { flag[4]= true; break; } } if(flag[0]==true && flag[1]==true && flag[2]==true && flag[3]==true && flag[4]==true) { System.out.println("YES"); } else { System.out.println("NO"); } } }}
Java
["10\n\n5\n\nTimur\n\n5\n\nmiurT\n\n5\n\nTrumi\n\n5\n\nmriTu\n\n5\n\ntimur\n\n4\n\nTimr\n\n6\n\nTimuur\n\n10\n\ncodeforces\n\n10\n\nTimurTimur\n\n5\n\nTIMUR"]
1 second
["YES\nYES\nYES\nYES\nNO\nNO\nNO\nNO\nNO\nNO"]
null
Java 17
standard input
[ "implementation" ]
6c137a74b36dede61037cb3b05167329
The first line of the input contains an integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The first line of each test case contains an integer $$$n$$$ $$$(1 \leq n \leq 10)$$$ — the length of string $$$s$$$. The second line of each test case contains a string $$$s$$$ consisting of only uppercase or lowercase Latin characters.
800
For each test case, output "YES" (without quotes) if $$$s$$$ satisfies the condition, and "NO" (without quotes) otherwise. You can output the answer in any case (for example, the strings "yEs", "yes", "Yes" and "YES" will be recognized as a positive answer).
standard output
PASSED
dd29674b82c4057d43dc0703ea516c0f
train_109.jsonl
1661871000
Timur likes his name. As a spelling of his name, he allows any permutation of the letters of the name. For example, the following strings are valid spellings of his name: Timur, miurT, Trumi, mriTu. Note that the correct spelling must have uppercased T and lowercased other letters.Today he wrote string $$$s$$$ of length $$$n$$$ consisting only of uppercase or lowercase Latin letters. He asks you to check if $$$s$$$ is the correct spelling of his name.
256 megabytes
import java.util.Scanner; import java.util.Arrays; public class HelloWorld { public static void main(String[] args) { Scanner sc = new Scanner (System.in); int te = sc.nextInt(); for(int t = 0; t < te; t++){ int n = sc.nextInt(); String str = sc.next(); if(str.length() < 5 || str.length() > 5){ System.out.println("NO"); continue; } char[] x = {'T','i','m','u','r'}; char[] y = str.toCharArray(); Arrays.sort(x); Arrays.sort(y); if(Arrays.equals(x, y)){ System.out.println("YES"); }else{ System.out.println("NO"); } } } }
Java
["10\n\n5\n\nTimur\n\n5\n\nmiurT\n\n5\n\nTrumi\n\n5\n\nmriTu\n\n5\n\ntimur\n\n4\n\nTimr\n\n6\n\nTimuur\n\n10\n\ncodeforces\n\n10\n\nTimurTimur\n\n5\n\nTIMUR"]
1 second
["YES\nYES\nYES\nYES\nNO\nNO\nNO\nNO\nNO\nNO"]
null
Java 17
standard input
[ "implementation" ]
6c137a74b36dede61037cb3b05167329
The first line of the input contains an integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The first line of each test case contains an integer $$$n$$$ $$$(1 \leq n \leq 10)$$$ — the length of string $$$s$$$. The second line of each test case contains a string $$$s$$$ consisting of only uppercase or lowercase Latin characters.
800
For each test case, output "YES" (without quotes) if $$$s$$$ satisfies the condition, and "NO" (without quotes) otherwise. You can output the answer in any case (for example, the strings "yEs", "yes", "Yes" and "YES" will be recognized as a positive answer).
standard output
PASSED
c2195825534f821b957e556a287140f3
train_109.jsonl
1661871000
Timur likes his name. As a spelling of his name, he allows any permutation of the letters of the name. For example, the following strings are valid spellings of his name: Timur, miurT, Trumi, mriTu. Note that the correct spelling must have uppercased T and lowercased other letters.Today he wrote string $$$s$$$ of length $$$n$$$ consisting only of uppercase or lowercase Latin letters. He asks you to check if $$$s$$$ is the correct spelling of his name.
256 megabytes
import java.util.*; import java.lang.*; import java.io.*; public class SpellCheck { public static void main (String[] args) { Scanner sc = new Scanner(System.in); int t = sc.nextInt(); while (t-- > 0) { int n = sc.nextInt(); String s = sc.next(); int vis[] = new int[5]; int f = 0; int g = 0; String x = "Timur"; for (int i = 0; i < n; i++) { char ch = s.charAt(i); if (x.indexOf(ch) >= 0) { if (vis[x.indexOf(ch)] == 1) g = 1; else vis[x.indexOf(ch)] = 1; } else if (x.indexOf(ch) == -1) { g = 1; break; } } if (g == 0) { for (int i = 0; i < 5; i++) { if (vis[i] == 0) { System.out.println("NO"); f = 1; break; } } } else System.out.println("NO"); if (f == 0 && g != 1) System.out.println("YES"); } sc.close(); } }
Java
["10\n\n5\n\nTimur\n\n5\n\nmiurT\n\n5\n\nTrumi\n\n5\n\nmriTu\n\n5\n\ntimur\n\n4\n\nTimr\n\n6\n\nTimuur\n\n10\n\ncodeforces\n\n10\n\nTimurTimur\n\n5\n\nTIMUR"]
1 second
["YES\nYES\nYES\nYES\nNO\nNO\nNO\nNO\nNO\nNO"]
null
Java 17
standard input
[ "implementation" ]
6c137a74b36dede61037cb3b05167329
The first line of the input contains an integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The first line of each test case contains an integer $$$n$$$ $$$(1 \leq n \leq 10)$$$ — the length of string $$$s$$$. The second line of each test case contains a string $$$s$$$ consisting of only uppercase or lowercase Latin characters.
800
For each test case, output "YES" (without quotes) if $$$s$$$ satisfies the condition, and "NO" (without quotes) otherwise. You can output the answer in any case (for example, the strings "yEs", "yes", "Yes" and "YES" will be recognized as a positive answer).
standard output
PASSED
482fe5251f505936e5d372bc96593ce1
train_109.jsonl
1661871000
Timur likes his name. As a spelling of his name, he allows any permutation of the letters of the name. For example, the following strings are valid spellings of his name: Timur, miurT, Trumi, mriTu. Note that the correct spelling must have uppercased T and lowercased other letters.Today he wrote string $$$s$$$ of length $$$n$$$ consisting only of uppercase or lowercase Latin letters. He asks you to check if $$$s$$$ is the correct spelling of his name.
256 megabytes
import java.io.*; import java.util.*; public class template { FastScanner scn; PrintWriter w; PrintStream fs; int MOD = 1000000007; int MAX = 200005; long mul(long x, long y) {long res = x * y; return (res >= MOD ? res % MOD : res);} long power(long x, long y) {if (y < 0) return 1; long res = 1; x %= MOD; while (y!=0) {if ((y & 1)==1)res = mul(res, x); y >>= 1; x = mul(x, x);} return res;} void ruffleSort(int[] a) {int n=a.length;Random r=new Random();for (int i=0; i<a.length; i++) {int oi=r.nextInt(n), temp=a[i];a[i]=a[oi];a[oi]=temp;}Arrays.sort(a);} void reverseSort(int[] arr){List<Integer> list = new ArrayList<>();for (int i=0; i<arr.length; i++){list.add(arr[i]);}Collections.sort(list, Collections.reverseOrder());for (int i = 0; i < arr.length; i++){arr[i] = list.get(i);}} boolean LOCAL; void debug(Object... o){if(LOCAL)System.err.println(Arrays.deepToString(o));} //SPEED IS NOT THE CRITERIA, CODE SHOULD BE A NO BRAINER, CMP KILLS, MOCIM void solve(){ int y=scn.nextInt(); int x=0; while (x!=y) { x++; int l =scn.nextInt(); String s=scn.next(); int i =0; if(l==5) { for(int j = 0; j <=4 ; j++ ) { if(s.charAt(j)=='T' || s.charAt(j)=='i' || s.charAt(j)=='m' ||s.charAt(j)=='u' || s.charAt(j)=='r') i++; for(int m = 0; m <= 4 ; m++) { if(s.charAt(j)==s.charAt(m)) i++; } } } if (i==10) { w.println("YES"); } else { w.println("NO"); } } } void run() { try { long ct = System.currentTimeMillis(); scn = new FastScanner(new File("input.txt")); w = new PrintWriter(new File("output.txt")); fs=new PrintStream("error.txt"); System.setErr(fs); LOCAL=true; solve(); w.close(); System.err.println(System.currentTimeMillis() - ct); } catch (FileNotFoundException e) { e.printStackTrace(); } } void runIO() { scn = new FastScanner(System.in); w = new PrintWriter(System.out); LOCAL=false; solve(); w.close(); } class FastScanner { BufferedReader br; StringTokenizer st; public FastScanner(File f) { try { br = new BufferedReader(new FileReader(f)); } catch (FileNotFoundException e) { e.printStackTrace(); } } public FastScanner(InputStream f) { br = new BufferedReader(new InputStreamReader(f)); } String next() { while (st == null || !st.hasMoreTokens()) { String s = null; try { s = br.readLine(); } catch (IOException e) { e.printStackTrace(); } if (s == null) return null; st = new StringTokenizer(s); } return st.nextToken(); } boolean hasMoreTokens() { while (st == null || !st.hasMoreTokens()) { String s = null; try { s = br.readLine(); } catch (IOException e) { e.printStackTrace(); } if (s == null) return false; st = new StringTokenizer(s); } return true; } int nextInt() { return Integer.parseInt(next()); } int[] nextIntArray(int n) { int a[] = new int[n]; for (int i = 0; i < n; i++) { a[i] = nextInt(); } return a; } long[] nextLongArray(int n) { long a[] = new long[n]; for (int i = 0; i < n; i++) { a[i] = nextLong(); } return a; } long nextLong() { return Long.parseLong(next()); } double nextDouble() { return Double.parseDouble(next()); } } int lowerBound(int[] arr, int x){int n = arr.length, si = 0, ei = n - 1;while(si <= ei){int mid = si + (ei - si)/2;if(arr[mid] == x){if(mid-1 >= 0 && arr[mid-1] == arr[mid]){ei = mid-1;}else{return mid;}}else if(arr[mid] > x){ei = mid - 1; }else{si = mid+1;}}return si; } int upperBound(int[] arr, int x){int n = arr.length, si = 0, ei = n - 1;while(si <= ei){int mid = si + (ei - si)/2;if(arr[mid] == x){if(mid+1 < n && arr[mid+1] == arr[mid]){si = mid+1;}else{return mid + 1;}}else if(arr[mid] > x){ei = mid - 1; }else{si = mid+1;}}return si; } int upperBound(ArrayList<Integer> list, int x){int n = list.size(), si = 0, ei = n - 1;while(si <= ei){int mid = si + (ei - si)/2;if(list.get(mid) == x){if(mid+1 < n && list.get(mid+1) == list.get(mid)){si = mid+1;}else{return mid + 1;}}else if(list.get(mid) > x){ei = mid - 1; }else{si = mid+1;}}return si; } void swap(int[] arr, int i, int j){int temp = arr[i];arr[i] = arr[j];arr[j] = temp;} long nextPowerOf2(long v){if (v == 0) return 1;v--;v |= v >> 1;v |= v >> 2;v |= v >> 4;v |= v >> 8;v |= v >> 16;v |= v >> 32;v++;return v;} int gcd(int a, int b) {if(a == 0){return b;}return gcd(b%a, a);} // TC- O(logmax(a,b)) boolean nextPermutation(int[] arr) {if(arr == null || arr.length <= 1){return false;}int last = arr.length-2;while(last >= 0){if(arr[last] < arr[last+1]){break;}last--;}if (last < 0){return false;}if(last >= 0){int nextGreater = arr.length-1;for(int i=arr.length-1; i>last; i--){if(arr[i] > arr[last]){nextGreater = i;break;}}swap(arr, last, nextGreater);}int i = last + 1, j = arr.length - 1;while(i < j){swap(arr, i++, j--);}return true;} public static void main(String[] args) { new template().runIO(); } }
Java
["10\n\n5\n\nTimur\n\n5\n\nmiurT\n\n5\n\nTrumi\n\n5\n\nmriTu\n\n5\n\ntimur\n\n4\n\nTimr\n\n6\n\nTimuur\n\n10\n\ncodeforces\n\n10\n\nTimurTimur\n\n5\n\nTIMUR"]
1 second
["YES\nYES\nYES\nYES\nNO\nNO\nNO\nNO\nNO\nNO"]
null
Java 17
standard input
[ "implementation" ]
6c137a74b36dede61037cb3b05167329
The first line of the input contains an integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The first line of each test case contains an integer $$$n$$$ $$$(1 \leq n \leq 10)$$$ — the length of string $$$s$$$. The second line of each test case contains a string $$$s$$$ consisting of only uppercase or lowercase Latin characters.
800
For each test case, output "YES" (without quotes) if $$$s$$$ satisfies the condition, and "NO" (without quotes) otherwise. You can output the answer in any case (for example, the strings "yEs", "yes", "Yes" and "YES" will be recognized as a positive answer).
standard output
PASSED
6718819aafa298dc2c8697b8dc38d4e2
train_109.jsonl
1661871000
Timur likes his name. As a spelling of his name, he allows any permutation of the letters of the name. For example, the following strings are valid spellings of his name: Timur, miurT, Trumi, mriTu. Note that the correct spelling must have uppercased T and lowercased other letters.Today he wrote string $$$s$$$ of length $$$n$$$ consisting only of uppercase or lowercase Latin letters. He asks you to check if $$$s$$$ is the correct spelling of his name.
256 megabytes
import java.util.*; public class Main { public static void main(String[] args){ Scanner sc=new Scanner(System.in); int t=sc.nextInt(); while(t-->0) { int n=sc.nextInt(); String str=sc.next(); if(n!=5) { System.out.println("NO"); continue; } int arr[]=new int[140]; int ans=0; for(int i=0;i<n;i++) { if((str.charAt(i)=='T' || str.charAt(i)=='i' || str.charAt(i)=='m' || str.charAt(i)=='u' ||str.charAt(i)=='r') && (arr[str.charAt(i)]==0) ){ arr[str.charAt(i)]++; continue; } else { ans=1; break; } } if(ans==0) System.out.println("YES"); else System.out.println("NO"); } } }
Java
["10\n\n5\n\nTimur\n\n5\n\nmiurT\n\n5\n\nTrumi\n\n5\n\nmriTu\n\n5\n\ntimur\n\n4\n\nTimr\n\n6\n\nTimuur\n\n10\n\ncodeforces\n\n10\n\nTimurTimur\n\n5\n\nTIMUR"]
1 second
["YES\nYES\nYES\nYES\nNO\nNO\nNO\nNO\nNO\nNO"]
null
Java 17
standard input
[ "implementation" ]
6c137a74b36dede61037cb3b05167329
The first line of the input contains an integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The first line of each test case contains an integer $$$n$$$ $$$(1 \leq n \leq 10)$$$ — the length of string $$$s$$$. The second line of each test case contains a string $$$s$$$ consisting of only uppercase or lowercase Latin characters.
800
For each test case, output "YES" (without quotes) if $$$s$$$ satisfies the condition, and "NO" (without quotes) otherwise. You can output the answer in any case (for example, the strings "yEs", "yes", "Yes" and "YES" will be recognized as a positive answer).
standard output
PASSED
1c5788cebaff1b68e3165fdefea14d3e
train_109.jsonl
1661871000
Timur likes his name. As a spelling of his name, he allows any permutation of the letters of the name. For example, the following strings are valid spellings of his name: Timur, miurT, Trumi, mriTu. Note that the correct spelling must have uppercased T and lowercased other letters.Today he wrote string $$$s$$$ of length $$$n$$$ consisting only of uppercase or lowercase Latin letters. He asks you to check if $$$s$$$ is the correct spelling of his name.
256 megabytes
import java.util.*; public class Practise { public static void main(String[] args) { Scanner sc=new Scanner(System.in); int t=sc.nextInt(); while(t-->0) { int n=sc.nextInt(); String s=sc.next(); char arr[]= {'T','i','m','u','r'}; Arrays.sort(arr); char brr[]=s.toCharArray(); Arrays.sort(brr); if(arr.length!=brr.length) { System.out.println("NO"); } else { boolean ans=Arrays.equals(arr, brr); if(ans) { System.out.println("YES"); } else System.out.println("NO"); } } } }
Java
["10\n\n5\n\nTimur\n\n5\n\nmiurT\n\n5\n\nTrumi\n\n5\n\nmriTu\n\n5\n\ntimur\n\n4\n\nTimr\n\n6\n\nTimuur\n\n10\n\ncodeforces\n\n10\n\nTimurTimur\n\n5\n\nTIMUR"]
1 second
["YES\nYES\nYES\nYES\nNO\nNO\nNO\nNO\nNO\nNO"]
null
Java 17
standard input
[ "implementation" ]
6c137a74b36dede61037cb3b05167329
The first line of the input contains an integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The first line of each test case contains an integer $$$n$$$ $$$(1 \leq n \leq 10)$$$ — the length of string $$$s$$$. The second line of each test case contains a string $$$s$$$ consisting of only uppercase or lowercase Latin characters.
800
For each test case, output "YES" (without quotes) if $$$s$$$ satisfies the condition, and "NO" (without quotes) otherwise. You can output the answer in any case (for example, the strings "yEs", "yes", "Yes" and "YES" will be recognized as a positive answer).
standard output
PASSED
d0d5f10f6f6d750dd34332ce465273f1
train_109.jsonl
1661871000
Timur likes his name. As a spelling of his name, he allows any permutation of the letters of the name. For example, the following strings are valid spellings of his name: Timur, miurT, Trumi, mriTu. Note that the correct spelling must have uppercased T and lowercased other letters.Today he wrote string $$$s$$$ of length $$$n$$$ consisting only of uppercase or lowercase Latin letters. He asks you to check if $$$s$$$ is the correct spelling of his name.
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.HashSet; import java.util.List; import java.util.Set; public class Main { public static Set<String> permutationFinder(String str) { Set<String> perm = new HashSet<String>(); //Handling error scenarios if (str == null) { return null; } else if (str.length() == 0) { perm.add(""); return perm; } char initial = str.charAt(0); // first character String rem = str.substring(1); // Full string without first character Set<String> words = permutationFinder(rem); for (String strNew : words) { for (int i = 0;i<=strNew.length();i++){ perm.add(charInsert(strNew, initial, i)); } } return perm; } public static String charInsert(String str, char c, int j) { String begin = str.substring(0, j); String end = str.substring(j); return begin + c + end; } public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); PrintWriter pw = new PrintWriter(System.out); int t = Integer.parseInt(br.readLine()); Set<String> s = permutationFinder("Timur"); while(t-->0) { br.readLine(); String str = br.readLine(); if(s.contains(str)) pw.println("YES"); else pw.println("NO"); } br.close(); pw.flush(); pw.close(); } }
Java
["10\n\n5\n\nTimur\n\n5\n\nmiurT\n\n5\n\nTrumi\n\n5\n\nmriTu\n\n5\n\ntimur\n\n4\n\nTimr\n\n6\n\nTimuur\n\n10\n\ncodeforces\n\n10\n\nTimurTimur\n\n5\n\nTIMUR"]
1 second
["YES\nYES\nYES\nYES\nNO\nNO\nNO\nNO\nNO\nNO"]
null
Java 17
standard input
[ "implementation" ]
6c137a74b36dede61037cb3b05167329
The first line of the input contains an integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The first line of each test case contains an integer $$$n$$$ $$$(1 \leq n \leq 10)$$$ — the length of string $$$s$$$. The second line of each test case contains a string $$$s$$$ consisting of only uppercase or lowercase Latin characters.
800
For each test case, output "YES" (without quotes) if $$$s$$$ satisfies the condition, and "NO" (without quotes) otherwise. You can output the answer in any case (for example, the strings "yEs", "yes", "Yes" and "YES" will be recognized as a positive answer).
standard output
PASSED
885f355d000ea279020d6675319807e6
train_109.jsonl
1661871000
Timur likes his name. As a spelling of his name, he allows any permutation of the letters of the name. For example, the following strings are valid spellings of his name: Timur, miurT, Trumi, mriTu. Note that the correct spelling must have uppercased T and lowercased other letters.Today he wrote string $$$s$$$ of length $$$n$$$ consisting only of uppercase or lowercase Latin letters. He asks you to check if $$$s$$$ is the correct spelling of his name.
256 megabytes
import java.io.*; import java.util.*; public class A_SpellCheck{ public static void main(String[] args) { MyScanner sc = new MyScanner(); out = new PrintWriter(new BufferedOutputStream(System.out)); // Start writing your solution here. ------------------------------------- /* int n = sc.nextInt(); // read input as integer long k = sc.nextLong(); // read input as long double d = sc.nextDouble(); // read input as double String str = sc.next(); // read input as String String s = sc.nextLine(); // read whole line as String int result = 3*n; out.println(result); // print via PrintWriter */ int t = Integer.parseInt(sc.nextLine()); while (t > 0){ t--; int line1 = Integer.parseInt(sc.nextLine()); String line2 = sc.nextLine(); int len = line2.length(); if (len != 5) { System.out.println("no"); continue; } char temp[] = line2.toCharArray(); // Sorting temp array using Arrays.sort(temp); if (temp[0] != 'T'){ System.out.println("no"); continue; } if (temp[1] != 'i'){ System.out.println("no"); continue; } if (temp[2] != 'm'){ System.out.println("no"); continue; } if (temp[3] != 'r'){ System.out.println("no"); continue; } if (temp[4] != 'u'){ System.out.println("no"); continue; } System.out.println("yes"); } // Stop writing your solution here. ------------------------------------- out.close(); } //-----------PrintWriter for faster output--------------------------------- public static PrintWriter out; //-----------MyScanner class for faster input---------- public static class MyScanner { BufferedReader br; StringTokenizer st; public MyScanner() { br = new BufferedReader(new InputStreamReader(System.in)); } String next() { while (st == null || !st.hasMoreElements()) { try { st = new StringTokenizer(br.readLine()); } catch (IOException e) { e.printStackTrace(); } } return st.nextToken(); } int nextInt() { return Integer.parseInt(next()); } long nextLong() { return Long.parseLong(next()); } double nextDouble() { return Double.parseDouble(next()); } String nextLine(){ String str = ""; try { str = br.readLine(); } catch (IOException e) { e.printStackTrace(); } return str; } } //-------------------------------------------------------- }
Java
["10\n\n5\n\nTimur\n\n5\n\nmiurT\n\n5\n\nTrumi\n\n5\n\nmriTu\n\n5\n\ntimur\n\n4\n\nTimr\n\n6\n\nTimuur\n\n10\n\ncodeforces\n\n10\n\nTimurTimur\n\n5\n\nTIMUR"]
1 second
["YES\nYES\nYES\nYES\nNO\nNO\nNO\nNO\nNO\nNO"]
null
Java 17
standard input
[ "implementation" ]
6c137a74b36dede61037cb3b05167329
The first line of the input contains an integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The first line of each test case contains an integer $$$n$$$ $$$(1 \leq n \leq 10)$$$ — the length of string $$$s$$$. The second line of each test case contains a string $$$s$$$ consisting of only uppercase or lowercase Latin characters.
800
For each test case, output "YES" (without quotes) if $$$s$$$ satisfies the condition, and "NO" (without quotes) otherwise. You can output the answer in any case (for example, the strings "yEs", "yes", "Yes" and "YES" will be recognized as a positive answer).
standard output
PASSED
69c09a424e3368fb06b83e22c1564db6
train_109.jsonl
1661871000
Timur likes his name. As a spelling of his name, he allows any permutation of the letters of the name. For example, the following strings are valid spellings of his name: Timur, miurT, Trumi, mriTu. Note that the correct spelling must have uppercased T and lowercased other letters.Today he wrote string $$$s$$$ of length $$$n$$$ consisting only of uppercase or lowercase Latin letters. He asks you to check if $$$s$$$ is the correct spelling of his name.
256 megabytes
import java.util.*; public class Codeforces { public static void main(String[] args) { Scanner lta = new Scanner(System.in); int t = lta.nextInt(); while (t-- >0) { int n = lta.nextInt(); String s = lta.next(); ArrayList<Character> alist = new ArrayList<>(); if (n == 5) { for (int i = 0; i < s.length(); i++) { if (!alist.contains(s.charAt(i))){ alist.add(s.charAt(i)); } } int temp = 0; Collections.sort(alist); if (alist.size() == 5){ if (alist.get(0) != 'T'){ temp = 1; } if (alist.get(1) != 'i'){ temp = 1; } if (alist.get(2) != 'm'){ temp = 1; } if (alist.get(3) != 'r'){ temp = 1; } if (alist.get(4) != 'u'){ temp = 1; } if (temp == 0){ System.out.println("YES"); } else { System.out.println("NO"); } } else { System.out.println("NO"); } } else { System.out.println("NO"); } } } }
Java
["10\n\n5\n\nTimur\n\n5\n\nmiurT\n\n5\n\nTrumi\n\n5\n\nmriTu\n\n5\n\ntimur\n\n4\n\nTimr\n\n6\n\nTimuur\n\n10\n\ncodeforces\n\n10\n\nTimurTimur\n\n5\n\nTIMUR"]
1 second
["YES\nYES\nYES\nYES\nNO\nNO\nNO\nNO\nNO\nNO"]
null
Java 17
standard input
[ "implementation" ]
6c137a74b36dede61037cb3b05167329
The first line of the input contains an integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The first line of each test case contains an integer $$$n$$$ $$$(1 \leq n \leq 10)$$$ — the length of string $$$s$$$. The second line of each test case contains a string $$$s$$$ consisting of only uppercase or lowercase Latin characters.
800
For each test case, output "YES" (without quotes) if $$$s$$$ satisfies the condition, and "NO" (without quotes) otherwise. You can output the answer in any case (for example, the strings "yEs", "yes", "Yes" and "YES" will be recognized as a positive answer).
standard output
PASSED
a89e2953d25b106fdfc5b8d85a2f4177
train_109.jsonl
1661871000
Timur likes his name. As a spelling of his name, he allows any permutation of the letters of the name. For example, the following strings are valid spellings of his name: Timur, miurT, Trumi, mriTu. Note that the correct spelling must have uppercased T and lowercased other letters.Today he wrote string $$$s$$$ of length $$$n$$$ consisting only of uppercase or lowercase Latin letters. He asks you to check if $$$s$$$ is the correct spelling of his name.
256 megabytes
/* * Problem Link: https://codeforces.com/contest/1722/problem/A * Problem Status: */ import java.util.*; public class PA { static Hashtable<Integer, Integer> Table = new Hashtable<Integer, Integer>(5); public static void TheAmazingFunction(String Name, int X) { if(X != 5) { System.out.println("NO"); return; } else { for(int i = 0 ; i < Name.length() ; i++) { if(Table.get((int)Name.charAt(i)) == null) { System.out.println("NO"); return; } else Table.remove((int)Name.charAt(i)); } System.out.println("YES"); return; } } public static void main(String[] args) { // ------------------------------------- SEPARATOR ------------------------------------- Scanner Reader = new Scanner(System.in); // ------------------------------------- SEPARATOR ------------------------------------- String Name = "Timur"; // ------------------------------------- SEPARATOR ------------------------------------- int N = Reader.nextInt(); while(N > 0) { int X = Reader.nextInt(); String Temp = Reader.next(); for(int i = 0 ; i < 5 ; i++) { Table.put((int)Name.charAt(i), 1); } TheAmazingFunction(Temp, X); N--; } Reader.close(); // ------------------------------------- SEPARATOR ------------------------------------- } }
Java
["10\n\n5\n\nTimur\n\n5\n\nmiurT\n\n5\n\nTrumi\n\n5\n\nmriTu\n\n5\n\ntimur\n\n4\n\nTimr\n\n6\n\nTimuur\n\n10\n\ncodeforces\n\n10\n\nTimurTimur\n\n5\n\nTIMUR"]
1 second
["YES\nYES\nYES\nYES\nNO\nNO\nNO\nNO\nNO\nNO"]
null
Java 17
standard input
[ "implementation" ]
6c137a74b36dede61037cb3b05167329
The first line of the input contains an integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The first line of each test case contains an integer $$$n$$$ $$$(1 \leq n \leq 10)$$$ — the length of string $$$s$$$. The second line of each test case contains a string $$$s$$$ consisting of only uppercase or lowercase Latin characters.
800
For each test case, output "YES" (without quotes) if $$$s$$$ satisfies the condition, and "NO" (without quotes) otherwise. You can output the answer in any case (for example, the strings "yEs", "yes", "Yes" and "YES" will be recognized as a positive answer).
standard output
PASSED
6f5b111d0afe0d738237f4cde38c3c23
train_109.jsonl
1661871000
Timur likes his name. As a spelling of his name, he allows any permutation of the letters of the name. For example, the following strings are valid spellings of his name: Timur, miurT, Trumi, mriTu. Note that the correct spelling must have uppercased T and lowercased other letters.Today he wrote string $$$s$$$ of length $$$n$$$ consisting only of uppercase or lowercase Latin letters. He asks you to check if $$$s$$$ is the correct spelling of his name.
256 megabytes
import java.util.*; public class ProblemA{ public static void main(String args[]){ HashMap<Character,Integer> temp = null; Scanner sc = new Scanner(System.in); HashMap<Character,Integer> map = new HashMap<Character,Integer>(); map.put('T',1); map.put('i',1); map.put('m',1); map.put('u',1); map.put('r',1); int n = sc.nextInt(); for(int i=0;i<n;i++){ int len = sc.nextInt(); String str = sc.next(); boolean flag = false; if(len!=map.size()){ System.out.println("NO"); continue; } temp = (HashMap<Character,Integer>) map.clone(); for(int j=0;j<len;j++){ char c = str.charAt(j); if(temp.get(c) == null || temp.get(c) == 0){ System.out.println("NO"); flag = true; break; } else{ temp.put(c,0); } } if(!flag){System.out.println("YES");} flag = false; } } }
Java
["10\n\n5\n\nTimur\n\n5\n\nmiurT\n\n5\n\nTrumi\n\n5\n\nmriTu\n\n5\n\ntimur\n\n4\n\nTimr\n\n6\n\nTimuur\n\n10\n\ncodeforces\n\n10\n\nTimurTimur\n\n5\n\nTIMUR"]
1 second
["YES\nYES\nYES\nYES\nNO\nNO\nNO\nNO\nNO\nNO"]
null
Java 17
standard input
[ "implementation" ]
6c137a74b36dede61037cb3b05167329
The first line of the input contains an integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The first line of each test case contains an integer $$$n$$$ $$$(1 \leq n \leq 10)$$$ — the length of string $$$s$$$. The second line of each test case contains a string $$$s$$$ consisting of only uppercase or lowercase Latin characters.
800
For each test case, output "YES" (without quotes) if $$$s$$$ satisfies the condition, and "NO" (without quotes) otherwise. You can output the answer in any case (for example, the strings "yEs", "yes", "Yes" and "YES" will be recognized as a positive answer).
standard output
PASSED
940875bb20b29262e1de96617c5d5753
train_109.jsonl
1661871000
Timur likes his name. As a spelling of his name, he allows any permutation of the letters of the name. For example, the following strings are valid spellings of his name: Timur, miurT, Trumi, mriTu. Note that the correct spelling must have uppercased T and lowercased other letters.Today he wrote string $$$s$$$ of length $$$n$$$ consisting only of uppercase or lowercase Latin letters. He asks you to check if $$$s$$$ is the correct spelling of his name.
256 megabytes
import java.util.Arrays; import java.util.Scanner; public class CodeForces814A { public static void main(String[] args) { Scanner input = new Scanner(System.in); int n = input.nextInt(); String caseN = "Timur"; for(int i =0;i<n;i++){ int o = input.nextInt(); String str = input.next(); char[] case1 = caseN.toCharArray(); char[] case2 = str.toCharArray(); Arrays.sort(case1); Arrays.sort(case2); String case3 = new String(case1); String case4 = new String(case2); if(case3.equals(case4)){ System.out.println("Yes"); }else{ System.out.println("No"); } } } }
Java
["10\n\n5\n\nTimur\n\n5\n\nmiurT\n\n5\n\nTrumi\n\n5\n\nmriTu\n\n5\n\ntimur\n\n4\n\nTimr\n\n6\n\nTimuur\n\n10\n\ncodeforces\n\n10\n\nTimurTimur\n\n5\n\nTIMUR"]
1 second
["YES\nYES\nYES\nYES\nNO\nNO\nNO\nNO\nNO\nNO"]
null
Java 17
standard input
[ "implementation" ]
6c137a74b36dede61037cb3b05167329
The first line of the input contains an integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The first line of each test case contains an integer $$$n$$$ $$$(1 \leq n \leq 10)$$$ — the length of string $$$s$$$. The second line of each test case contains a string $$$s$$$ consisting of only uppercase or lowercase Latin characters.
800
For each test case, output "YES" (without quotes) if $$$s$$$ satisfies the condition, and "NO" (without quotes) otherwise. You can output the answer in any case (for example, the strings "yEs", "yes", "Yes" and "YES" will be recognized as a positive answer).
standard output
PASSED
ecfddb5d869b48621b2c9a444739c2a8
train_109.jsonl
1661871000
Timur likes his name. As a spelling of his name, he allows any permutation of the letters of the name. For example, the following strings are valid spellings of his name: Timur, miurT, Trumi, mriTu. Note that the correct spelling must have uppercased T and lowercased other letters.Today he wrote string $$$s$$$ of length $$$n$$$ consisting only of uppercase or lowercase Latin letters. He asks you to check if $$$s$$$ is the correct spelling of his name.
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.Random; import java.util.StringTokenizer; public class A { public static void main(String[] args) { FastScanner fs=new FastScanner(); // PrintWriter out=new PrintWriter(System.out); int t=fs.nextInt(); while(t-->0){ int n; n=fs.nextInt(); String s=fs.next(); String org="Timur"; char[] c=org.toCharArray(); char[] d=s.toCharArray(); Arrays.sort(c); Arrays.sort(d); String s1=new String(c); String s2=new String(d); if(s1.equals(s2)){ System.out.println("Yes"); } else{ System.out.println("No"); } } } static final Random random=new Random(); static final int mod=1_000_000_007; static void ruffleSort(int[] a) { int n=a.length;//shuffle, then sort for (int i=0; i<n; i++) { int oi=random.nextInt(n), temp=a[oi]; a[oi]=a[i]; a[i]=temp; } Arrays.sort(a); } static long add(long a, long b) { return (a+b)%mod; } static long sub(long a, long b) { return ((a-b)%mod+mod)%mod; } static long mul(long a, long b) { return (a*b)%mod; } static long exp(long base, long exp) { if (exp==0) return 1; long half=exp(base, exp/2); if (exp%2==0) return mul(half, half); return mul(half, mul(half, base)); } static long[] factorials=new long[2_000_001]; static long[] invFactorials=new long[2_000_001]; static void precompFacts() { factorials[0]=invFactorials[0]=1; for (int i=1; i<factorials.length; i++) factorials[i]=mul(factorials[i-1], i); invFactorials[factorials.length-1]=exp(factorials[factorials.length-1], mod-2); for (int i=invFactorials.length-2; i>=0; i--) invFactorials[i]=mul(invFactorials[i+1], i+1); } static long nCk(int n, int k) { return mul(factorials[n], mul(invFactorials[k], invFactorials[n-k])); } static void sort(int[] a) { ArrayList<Integer> l=new ArrayList<>(); for (int i:a) l.add(i); Collections.sort(l); for (int i=0; i<a.length; i++) a[i]=l.get(i); } static class FastScanner { BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st=new StringTokenizer(""); String next() { while (!st.hasMoreTokens()) try { st=new StringTokenizer(br.readLine()); } catch (IOException e) { e.printStackTrace(); } return st.nextToken(); } int nextInt() { return Integer.parseInt(next()); } int[] readArray(int n) { int[] a=new int[n]; for (int i=0; i<n; i++) a[i]=nextInt(); return a; } long nextLong() { return Long.parseLong(next()); } } }
Java
["10\n\n5\n\nTimur\n\n5\n\nmiurT\n\n5\n\nTrumi\n\n5\n\nmriTu\n\n5\n\ntimur\n\n4\n\nTimr\n\n6\n\nTimuur\n\n10\n\ncodeforces\n\n10\n\nTimurTimur\n\n5\n\nTIMUR"]
1 second
["YES\nYES\nYES\nYES\nNO\nNO\nNO\nNO\nNO\nNO"]
null
Java 17
standard input
[ "implementation" ]
6c137a74b36dede61037cb3b05167329
The first line of the input contains an integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The first line of each test case contains an integer $$$n$$$ $$$(1 \leq n \leq 10)$$$ — the length of string $$$s$$$. The second line of each test case contains a string $$$s$$$ consisting of only uppercase or lowercase Latin characters.
800
For each test case, output "YES" (without quotes) if $$$s$$$ satisfies the condition, and "NO" (without quotes) otherwise. You can output the answer in any case (for example, the strings "yEs", "yes", "Yes" and "YES" will be recognized as a positive answer).
standard output
PASSED
21b7e66c3e28ff121905e29072e6f865
train_109.jsonl
1661871000
Timur likes his name. As a spelling of his name, he allows any permutation of the letters of the name. For example, the following strings are valid spellings of his name: Timur, miurT, Trumi, mriTu. Note that the correct spelling must have uppercased T and lowercased other letters.Today he wrote string $$$s$$$ of length $$$n$$$ consisting only of uppercase or lowercase Latin letters. He asks you to check if $$$s$$$ is the correct spelling of his name.
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.Random; import java.util.StringTokenizer; public class A { public static void main(String[] args) { FastScanner fs=new FastScanner(); // PrintWriter out=new PrintWriter(System.out); int t=fs.nextInt(); for(int i=0;i<t;i++){ int n; n=fs.nextInt(); String s=fs.next(); String org="Timur"; char[] c=org.toCharArray(); char[] d=s.toCharArray(); Arrays.sort(c); Arrays.sort(d); String s1=new String(c); String s2=new String(d); if(s1.equals(s2)){ System.out.println("Yes"); } else{ System.out.println("No"); } } } static final Random random=new Random(); static final int mod=1_000_000_007; static void ruffleSort(int[] a) { int n=a.length;//shuffle, then sort for (int i=0; i<n; i++) { int oi=random.nextInt(n), temp=a[oi]; a[oi]=a[i]; a[i]=temp; } Arrays.sort(a); } static long add(long a, long b) { return (a+b)%mod; } static long sub(long a, long b) { return ((a-b)%mod+mod)%mod; } static long mul(long a, long b) { return (a*b)%mod; } static long exp(long base, long exp) { if (exp==0) return 1; long half=exp(base, exp/2); if (exp%2==0) return mul(half, half); return mul(half, mul(half, base)); } static long[] factorials=new long[2_000_001]; static long[] invFactorials=new long[2_000_001]; static void precompFacts() { factorials[0]=invFactorials[0]=1; for (int i=1; i<factorials.length; i++) factorials[i]=mul(factorials[i-1], i); invFactorials[factorials.length-1]=exp(factorials[factorials.length-1], mod-2); for (int i=invFactorials.length-2; i>=0; i--) invFactorials[i]=mul(invFactorials[i+1], i+1); } static long nCk(int n, int k) { return mul(factorials[n], mul(invFactorials[k], invFactorials[n-k])); } static void sort(int[] a) { ArrayList<Integer> l=new ArrayList<>(); for (int i:a) l.add(i); Collections.sort(l); for (int i=0; i<a.length; i++) a[i]=l.get(i); } static class FastScanner { BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st=new StringTokenizer(""); String next() { while (!st.hasMoreTokens()) try { st=new StringTokenizer(br.readLine()); } catch (IOException e) { e.printStackTrace(); } return st.nextToken(); } int nextInt() { return Integer.parseInt(next()); } int[] readArray(int n) { int[] a=new int[n]; for (int i=0; i<n; i++) a[i]=nextInt(); return a; } long nextLong() { return Long.parseLong(next()); } } }
Java
["10\n\n5\n\nTimur\n\n5\n\nmiurT\n\n5\n\nTrumi\n\n5\n\nmriTu\n\n5\n\ntimur\n\n4\n\nTimr\n\n6\n\nTimuur\n\n10\n\ncodeforces\n\n10\n\nTimurTimur\n\n5\n\nTIMUR"]
1 second
["YES\nYES\nYES\nYES\nNO\nNO\nNO\nNO\nNO\nNO"]
null
Java 17
standard input
[ "implementation" ]
6c137a74b36dede61037cb3b05167329
The first line of the input contains an integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The first line of each test case contains an integer $$$n$$$ $$$(1 \leq n \leq 10)$$$ — the length of string $$$s$$$. The second line of each test case contains a string $$$s$$$ consisting of only uppercase or lowercase Latin characters.
800
For each test case, output "YES" (without quotes) if $$$s$$$ satisfies the condition, and "NO" (without quotes) otherwise. You can output the answer in any case (for example, the strings "yEs", "yes", "Yes" and "YES" will be recognized as a positive answer).
standard output
PASSED
272354b7f24e172e479c80b8f3c5c24d
train_109.jsonl
1661871000
Timur likes his name. As a spelling of his name, he allows any permutation of the letters of the name. For example, the following strings are valid spellings of his name: Timur, miurT, Trumi, mriTu. Note that the correct spelling must have uppercased T and lowercased other letters.Today he wrote string $$$s$$$ of length $$$n$$$ consisting only of uppercase or lowercase Latin letters. He asks you to check if $$$s$$$ is the correct spelling of his name.
256 megabytes
import java.util.*; import java.io.*; public class ASpellCheck { // For fast input output static class FastReader { BufferedReader br; StringTokenizer st; public FastReader() { try {br = new BufferedReader( new FileReader("input.txt")); PrintStream out = new PrintStream(new FileOutputStream("output.txt")); System.setOut(out);} catch(Exception e) { br = new BufferedReader(new InputStreamReader(System.in));} } String next() { while (st == null || !st.hasMoreElements()) { try {st = new StringTokenizer(br.readLine());} catch (IOException e) { e.printStackTrace();} } return st.nextToken(); } int nextInt() { return Integer.parseInt(next()); } long nextLong() { return Long.parseLong(next()); } double nextDouble() {return Double.parseDouble(next()); } String nextLine() { String str = ""; try { str = br.readLine(); } catch (IOException e) { e.printStackTrace(); } return str; } } // end of fast i/o code public static void main(String[] args) { FastReader reader = new FastReader(); long t = reader.nextLong(); while (t > 0) { int l = reader.nextInt(); String str = reader.nextLine(); boolean flag = true; if(l != 5) { flag = false; } HashSet<Character> set = new HashSet<Character>(); HashSet<Character> set2 = new HashSet<Character>(); set.add('T'); set.add('i'); set.add('m'); set.add('u'); set.add('r'); for(char ch : str.toCharArray()){ if(!set.contains(ch)) { flag = false; } set2.add(ch); } if(set2.size() != 5){ flag = false; } if(flag) System.out.println("YES"); else System.out.println("NO"); t--; } } }
Java
["10\n\n5\n\nTimur\n\n5\n\nmiurT\n\n5\n\nTrumi\n\n5\n\nmriTu\n\n5\n\ntimur\n\n4\n\nTimr\n\n6\n\nTimuur\n\n10\n\ncodeforces\n\n10\n\nTimurTimur\n\n5\n\nTIMUR"]
1 second
["YES\nYES\nYES\nYES\nNO\nNO\nNO\nNO\nNO\nNO"]
null
Java 17
standard input
[ "implementation" ]
6c137a74b36dede61037cb3b05167329
The first line of the input contains an integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The first line of each test case contains an integer $$$n$$$ $$$(1 \leq n \leq 10)$$$ — the length of string $$$s$$$. The second line of each test case contains a string $$$s$$$ consisting of only uppercase or lowercase Latin characters.
800
For each test case, output "YES" (without quotes) if $$$s$$$ satisfies the condition, and "NO" (without quotes) otherwise. You can output the answer in any case (for example, the strings "yEs", "yes", "Yes" and "YES" will be recognized as a positive answer).
standard output
PASSED
0d861f607ddf91147964a3f73b15e4d4
train_109.jsonl
1661871000
Timur likes his name. As a spelling of his name, he allows any permutation of the letters of the name. For example, the following strings are valid spellings of his name: Timur, miurT, Trumi, mriTu. Note that the correct spelling must have uppercased T and lowercased other letters.Today he wrote string $$$s$$$ of length $$$n$$$ consisting only of uppercase or lowercase Latin letters. He asks you to check if $$$s$$$ is the correct spelling of his name.
256 megabytes
import java.io.*; import java.util.*; import java.util.stream.*; public class Codeforces extends PrintWriter { Codeforces() { super(System.out); } Scanner sc = new Scanner(System.in); public static void main(String[] $) { Codeforces o = new Codeforces(); o.main(); o.flush(); o.close(); } final int mod = 998244353; void main() { int t = sc.nextInt(); while(t-->0){ int n = sc.nextInt(); String str = sc.next(); if(n==5 && str.contains("T") && str.contains("i") && str.contains("m") && str.contains("u") && str.contains("r")){ println("YES"); } else{ println("NO"); } } } }
Java
["10\n\n5\n\nTimur\n\n5\n\nmiurT\n\n5\n\nTrumi\n\n5\n\nmriTu\n\n5\n\ntimur\n\n4\n\nTimr\n\n6\n\nTimuur\n\n10\n\ncodeforces\n\n10\n\nTimurTimur\n\n5\n\nTIMUR"]
1 second
["YES\nYES\nYES\nYES\nNO\nNO\nNO\nNO\nNO\nNO"]
null
Java 17
standard input
[ "implementation" ]
6c137a74b36dede61037cb3b05167329
The first line of the input contains an integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The first line of each test case contains an integer $$$n$$$ $$$(1 \leq n \leq 10)$$$ — the length of string $$$s$$$. The second line of each test case contains a string $$$s$$$ consisting of only uppercase or lowercase Latin characters.
800
For each test case, output "YES" (without quotes) if $$$s$$$ satisfies the condition, and "NO" (without quotes) otherwise. You can output the answer in any case (for example, the strings "yEs", "yes", "Yes" and "YES" will be recognized as a positive answer).
standard output
PASSED
a3ca70523e2e3810900aad51dac1f9ad
train_109.jsonl
1661871000
Timur likes his name. As a spelling of his name, he allows any permutation of the letters of the name. For example, the following strings are valid spellings of his name: Timur, miurT, Trumi, mriTu. Note that the correct spelling must have uppercased T and lowercased other letters.Today he wrote string $$$s$$$ of length $$$n$$$ consisting only of uppercase or lowercase Latin letters. He asks you to check if $$$s$$$ is the correct spelling of his name.
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.HashSet; import java.util.List; import java.util.Set; import java.util.StringTokenizer; public class A { public static void main(String[] args) { FastScanner fs = new FastScanner(); int tt = 1; tt = fs.nextInt(); while (tt-- > 0) { Set<Character> st = new HashSet<>(List.of('T', 'i', 'm', 'u', 'r')); int n = fs.nextInt(); String str = fs.next(); if (n != 5) { System.out.println("NO"); continue; } boolean isValid = true; for (char ch : str.toCharArray()) isValid = isValid && st.remove(ch); if (isValid) System.out.println("YES"); else System.out.println("NO"); } } static class FastScanner { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(""); String next() { while (!st.hasMoreTokens()) try { st = new StringTokenizer(br.readLine()); } catch (IOException e) { e.printStackTrace(); } return st.nextToken(); } int nextInt() { return Integer.parseInt(next()); } int[] readArray(int n) { int[] a = new int[n]; for (int i = 0; i < n; i++) a[i] = nextInt(); return a; } long nextLong() { return Long.parseLong(next()); } } }
Java
["10\n\n5\n\nTimur\n\n5\n\nmiurT\n\n5\n\nTrumi\n\n5\n\nmriTu\n\n5\n\ntimur\n\n4\n\nTimr\n\n6\n\nTimuur\n\n10\n\ncodeforces\n\n10\n\nTimurTimur\n\n5\n\nTIMUR"]
1 second
["YES\nYES\nYES\nYES\nNO\nNO\nNO\nNO\nNO\nNO"]
null
Java 17
standard input
[ "implementation" ]
6c137a74b36dede61037cb3b05167329
The first line of the input contains an integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The first line of each test case contains an integer $$$n$$$ $$$(1 \leq n \leq 10)$$$ — the length of string $$$s$$$. The second line of each test case contains a string $$$s$$$ consisting of only uppercase or lowercase Latin characters.
800
For each test case, output "YES" (without quotes) if $$$s$$$ satisfies the condition, and "NO" (without quotes) otherwise. You can output the answer in any case (for example, the strings "yEs", "yes", "Yes" and "YES" will be recognized as a positive answer).
standard output
PASSED
aa6c81db23d0a240fa5558b85f0a6d3f
train_109.jsonl
1661871000
Timur likes his name. As a spelling of his name, he allows any permutation of the letters of the name. For example, the following strings are valid spellings of his name: Timur, miurT, Trumi, mriTu. Note that the correct spelling must have uppercased T and lowercased other letters.Today he wrote string $$$s$$$ of length $$$n$$$ consisting only of uppercase or lowercase Latin letters. He asks you to check if $$$s$$$ is the correct spelling of his name.
256 megabytes
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc=new Scanner(System.in); int t=sc.nextInt(); for(int j=0;j<t;j++){ int n=sc.nextInt(); String s=sc.next(); if(s.length()!=5){ System.out.println("NO"); } else{ int T=0; int i=0; int m=0; int u=0; int r=0; for(int k=0;k<s.length();k++){ if(s.charAt(k)=='T'){ T=1; } else if(s.charAt(k)=='i'){ i=1; } else if(s.charAt(k)=='m'){ m=1; } else if(s.charAt(k)=='u'){ u=1; } else if(s.charAt(k)=='r'){ r=1; } } if(T==1 && i==1 && m==1 && u==1 && r==1){ System.out.println("YES"); } else{ System.out.println("NO"); } } } } }
Java
["10\n\n5\n\nTimur\n\n5\n\nmiurT\n\n5\n\nTrumi\n\n5\n\nmriTu\n\n5\n\ntimur\n\n4\n\nTimr\n\n6\n\nTimuur\n\n10\n\ncodeforces\n\n10\n\nTimurTimur\n\n5\n\nTIMUR"]
1 second
["YES\nYES\nYES\nYES\nNO\nNO\nNO\nNO\nNO\nNO"]
null
Java 17
standard input
[ "implementation" ]
6c137a74b36dede61037cb3b05167329
The first line of the input contains an integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The first line of each test case contains an integer $$$n$$$ $$$(1 \leq n \leq 10)$$$ — the length of string $$$s$$$. The second line of each test case contains a string $$$s$$$ consisting of only uppercase or lowercase Latin characters.
800
For each test case, output "YES" (without quotes) if $$$s$$$ satisfies the condition, and "NO" (without quotes) otherwise. You can output the answer in any case (for example, the strings "yEs", "yes", "Yes" and "YES" will be recognized as a positive answer).
standard output
PASSED
f8be06aad3c80c658a0d08df92bfe2c2
train_109.jsonl
1661871000
Timur likes his name. As a spelling of his name, he allows any permutation of the letters of the name. For example, the following strings are valid spellings of his name: Timur, miurT, Trumi, mriTu. Note that the correct spelling must have uppercased T and lowercased other letters.Today he wrote string $$$s$$$ of length $$$n$$$ consisting only of uppercase or lowercase Latin letters. He asks you to check if $$$s$$$ is the correct spelling of his name.
256 megabytes
import java.util.Scanner; import java.util.Arrays; public class PRL_A { public static void main(String[] args) { Scanner sc=new Scanner(System.in); int time= Integer.parseInt(sc.nextLine()); String []Ket_qua= new String[time]; char tn[] = {'T','i','m','u','r'}; Arrays.sort(tn); for (int i=0;i<time;i++) { int sokt= Integer.parseInt(sc.nextLine()); char []input = new char[sokt]; String s1= sc.nextLine(); input= s1.toCharArray(); Arrays.sort(input); if(Arrays.equals(tn, input)) Ket_qua[i]="Yes"; else Ket_qua[i]="No"; } for (int i=0;i<time;i++) { System.out.println(Ket_qua[i]); } } }
Java
["10\n\n5\n\nTimur\n\n5\n\nmiurT\n\n5\n\nTrumi\n\n5\n\nmriTu\n\n5\n\ntimur\n\n4\n\nTimr\n\n6\n\nTimuur\n\n10\n\ncodeforces\n\n10\n\nTimurTimur\n\n5\n\nTIMUR"]
1 second
["YES\nYES\nYES\nYES\nNO\nNO\nNO\nNO\nNO\nNO"]
null
Java 17
standard input
[ "implementation" ]
6c137a74b36dede61037cb3b05167329
The first line of the input contains an integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The first line of each test case contains an integer $$$n$$$ $$$(1 \leq n \leq 10)$$$ — the length of string $$$s$$$. The second line of each test case contains a string $$$s$$$ consisting of only uppercase or lowercase Latin characters.
800
For each test case, output "YES" (without quotes) if $$$s$$$ satisfies the condition, and "NO" (without quotes) otherwise. You can output the answer in any case (for example, the strings "yEs", "yes", "Yes" and "YES" will be recognized as a positive answer).
standard output
PASSED
ab581cc44f2399939a93268102cde4a3
train_109.jsonl
1661871000
Timur likes his name. As a spelling of his name, he allows any permutation of the letters of the name. For example, the following strings are valid spellings of his name: Timur, miurT, Trumi, mriTu. Note that the correct spelling must have uppercased T and lowercased other letters.Today he wrote string $$$s$$$ of length $$$n$$$ consisting only of uppercase or lowercase Latin letters. He asks you to check if $$$s$$$ is the correct spelling of his name.
256 megabytes
import java.util.* ; //import java.io.* ; public class Spellcheck1 { public static void main(String args[] ) { Scanner in = new Scanner(System.in) ; int t = in.nextInt() ; String s = "Timur" ; char cs[] = s.toCharArray() ; Arrays.sort(cs) ; while( t-- > 0 ) { int n = in.nextInt() ; String x = in.next() ; //x = x.substring(0, n ); char cx[] = x.toCharArray() ; Arrays.sort(cx) ; if( Arrays.equals( cs, cx ) ) { System.out.println("YES"); } else { System.out.println("NO"); } } } }
Java
["10\n\n5\n\nTimur\n\n5\n\nmiurT\n\n5\n\nTrumi\n\n5\n\nmriTu\n\n5\n\ntimur\n\n4\n\nTimr\n\n6\n\nTimuur\n\n10\n\ncodeforces\n\n10\n\nTimurTimur\n\n5\n\nTIMUR"]
1 second
["YES\nYES\nYES\nYES\nNO\nNO\nNO\nNO\nNO\nNO"]
null
Java 17
standard input
[ "implementation" ]
6c137a74b36dede61037cb3b05167329
The first line of the input contains an integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The first line of each test case contains an integer $$$n$$$ $$$(1 \leq n \leq 10)$$$ — the length of string $$$s$$$. The second line of each test case contains a string $$$s$$$ consisting of only uppercase or lowercase Latin characters.
800
For each test case, output "YES" (without quotes) if $$$s$$$ satisfies the condition, and "NO" (without quotes) otherwise. You can output the answer in any case (for example, the strings "yEs", "yes", "Yes" and "YES" will be recognized as a positive answer).
standard output
PASSED
4c2d693ca9080ebf16faf0b699021fb3
train_109.jsonl
1661871000
Timur likes his name. As a spelling of his name, he allows any permutation of the letters of the name. For example, the following strings are valid spellings of his name: Timur, miurT, Trumi, mriTu. Note that the correct spelling must have uppercased T and lowercased other letters.Today he wrote string $$$s$$$ of length $$$n$$$ consisting only of uppercase or lowercase Latin letters. He asks you to check if $$$s$$$ is the correct spelling of his name.
256 megabytes
import java.util.* ; import java.io.* ; public class Spellcheck1 { public static void main(String args[] ) { Scanner in = new Scanner(System.in) ; int t = in.nextInt() ; String s = "Timur" ; char cs[] = s.toCharArray() ; Arrays.sort(cs) ; while( t-- > 0 ) { int n = in.nextInt() ; String x = in.next() ; x = x.substring(0, n ); char cx[] = x.toCharArray() ; Arrays.sort(cx) ; if( Arrays.equals( cs, cx ) ) { System.out.println("YES"); } else { System.out.println("NO"); } } } }
Java
["10\n\n5\n\nTimur\n\n5\n\nmiurT\n\n5\n\nTrumi\n\n5\n\nmriTu\n\n5\n\ntimur\n\n4\n\nTimr\n\n6\n\nTimuur\n\n10\n\ncodeforces\n\n10\n\nTimurTimur\n\n5\n\nTIMUR"]
1 second
["YES\nYES\nYES\nYES\nNO\nNO\nNO\nNO\nNO\nNO"]
null
Java 17
standard input
[ "implementation" ]
6c137a74b36dede61037cb3b05167329
The first line of the input contains an integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The first line of each test case contains an integer $$$n$$$ $$$(1 \leq n \leq 10)$$$ — the length of string $$$s$$$. The second line of each test case contains a string $$$s$$$ consisting of only uppercase or lowercase Latin characters.
800
For each test case, output "YES" (without quotes) if $$$s$$$ satisfies the condition, and "NO" (without quotes) otherwise. You can output the answer in any case (for example, the strings "yEs", "yes", "Yes" and "YES" will be recognized as a positive answer).
standard output
PASSED
701ed1e1d24b0edda729a4643ab4bee4
train_109.jsonl
1661871000
Timur likes his name. As a spelling of his name, he allows any permutation of the letters of the name. For example, the following strings are valid spellings of his name: Timur, miurT, Trumi, mriTu. Note that the correct spelling must have uppercased T and lowercased other letters.Today he wrote string $$$s$$$ of length $$$n$$$ consisting only of uppercase or lowercase Latin letters. He asks you to check if $$$s$$$ is the correct spelling of his name.
256 megabytes
import java.util.*; import java.io.*; public class Spellcheck { public static void main(String args[]) { //String nam [] = {"Timur","miurT","Trumi", "mriTu" } ; int t ; Scanner in = new Scanner(System.in) ; t = in.nextInt(); for( int i = 0 ; i < t && in.hasNext() ; i = i + 1 ) { int n = in.nextInt() ; String s = in.next() ; s = s.substring(0,n) ; int x = s.length() ; if( x == 5 && s.contains("T") && s.contains("i") && s.contains("m") && s.contains("r") && s.contains("u") ) { System.out.println("YES"); } else { System.out.println("NO"); } } } }
Java
["10\n\n5\n\nTimur\n\n5\n\nmiurT\n\n5\n\nTrumi\n\n5\n\nmriTu\n\n5\n\ntimur\n\n4\n\nTimr\n\n6\n\nTimuur\n\n10\n\ncodeforces\n\n10\n\nTimurTimur\n\n5\n\nTIMUR"]
1 second
["YES\nYES\nYES\nYES\nNO\nNO\nNO\nNO\nNO\nNO"]
null
Java 17
standard input
[ "implementation" ]
6c137a74b36dede61037cb3b05167329
The first line of the input contains an integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The first line of each test case contains an integer $$$n$$$ $$$(1 \leq n \leq 10)$$$ — the length of string $$$s$$$. The second line of each test case contains a string $$$s$$$ consisting of only uppercase or lowercase Latin characters.
800
For each test case, output "YES" (without quotes) if $$$s$$$ satisfies the condition, and "NO" (without quotes) otherwise. You can output the answer in any case (for example, the strings "yEs", "yes", "Yes" and "YES" will be recognized as a positive answer).
standard output
PASSED
e2f09776ee998c78058c463173808a8f
train_109.jsonl
1661871000
Timur likes his name. As a spelling of his name, he allows any permutation of the letters of the name. For example, the following strings are valid spellings of his name: Timur, miurT, Trumi, mriTu. Note that the correct spelling must have uppercased T and lowercased other letters.Today he wrote string $$$s$$$ of length $$$n$$$ consisting only of uppercase or lowercase Latin letters. He asks you to check if $$$s$$$ is the correct spelling of his name.
256 megabytes
import java.util.*; public class SpellCheck { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int numTestCase = sc.nextInt(); int arr[] = new int[numTestCase]; Arrays.fill(arr, 1); for (int i = 0; i < numTestCase; i++) { int n = sc.nextInt(); String m = sc.next(); String comp = "Timur"; char c1[] = comp.toCharArray(); char c2[] = m.toCharArray(); Arrays.sort(c1); Arrays.sort(c2); if (n == 5) { for (int j = 0; j < 5; j++) { if (c1[j] != c2[j]) { arr[i] = 0; break; } } } else { arr[i] = 0; } } for (int i = 0; i < numTestCase; i++) { if (arr[i] == 1) System.out.println("Yes"); else System.out.println("No"); } } }
Java
["10\n\n5\n\nTimur\n\n5\n\nmiurT\n\n5\n\nTrumi\n\n5\n\nmriTu\n\n5\n\ntimur\n\n4\n\nTimr\n\n6\n\nTimuur\n\n10\n\ncodeforces\n\n10\n\nTimurTimur\n\n5\n\nTIMUR"]
1 second
["YES\nYES\nYES\nYES\nNO\nNO\nNO\nNO\nNO\nNO"]
null
Java 17
standard input
[ "implementation" ]
6c137a74b36dede61037cb3b05167329
The first line of the input contains an integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The first line of each test case contains an integer $$$n$$$ $$$(1 \leq n \leq 10)$$$ — the length of string $$$s$$$. The second line of each test case contains a string $$$s$$$ consisting of only uppercase or lowercase Latin characters.
800
For each test case, output "YES" (without quotes) if $$$s$$$ satisfies the condition, and "NO" (without quotes) otherwise. You can output the answer in any case (for example, the strings "yEs", "yes", "Yes" and "YES" will be recognized as a positive answer).
standard output
PASSED
decb9142cd4dfc19fa13ba9db268b4a0
train_109.jsonl
1661871000
Timur likes his name. As a spelling of his name, he allows any permutation of the letters of the name. For example, the following strings are valid spellings of his name: Timur, miurT, Trumi, mriTu. Note that the correct spelling must have uppercased T and lowercased other letters.Today he wrote string $$$s$$$ of length $$$n$$$ consisting only of uppercase or lowercase Latin letters. He asks you to check if $$$s$$$ is the correct spelling of his name.
256 megabytes
import java.util.*; public class contest_div4 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int t = sc.nextInt(); for (int i = 0; i < t; i++) { // System.out.println(t); int x = sc.nextInt(); String s = sc.next(); int T = 0, I = 0, m = 0, u = 0, r = 0; if (x == 5) { for (int j = 0; j < s.length(); j++) { if (s.charAt(j) == 'T') { T++; } else if (s.charAt(j) == 'i') { I++; } else if (s.charAt(j) == 'm') { m++; } else if (s.charAt(j) == 'u') { u++; } else if (s.charAt(j) == 'r') { r++; } } } if (T == 1 && I == 1 && m == 1 && u == 1 && r == 1) { System.out.println("YES"); } else { System.out.println("NO"); } // sc.close(); } sc.close(); } }
Java
["10\n\n5\n\nTimur\n\n5\n\nmiurT\n\n5\n\nTrumi\n\n5\n\nmriTu\n\n5\n\ntimur\n\n4\n\nTimr\n\n6\n\nTimuur\n\n10\n\ncodeforces\n\n10\n\nTimurTimur\n\n5\n\nTIMUR"]
1 second
["YES\nYES\nYES\nYES\nNO\nNO\nNO\nNO\nNO\nNO"]
null
Java 17
standard input
[ "implementation" ]
6c137a74b36dede61037cb3b05167329
The first line of the input contains an integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The first line of each test case contains an integer $$$n$$$ $$$(1 \leq n \leq 10)$$$ — the length of string $$$s$$$. The second line of each test case contains a string $$$s$$$ consisting of only uppercase or lowercase Latin characters.
800
For each test case, output "YES" (without quotes) if $$$s$$$ satisfies the condition, and "NO" (without quotes) otherwise. You can output the answer in any case (for example, the strings "yEs", "yes", "Yes" and "YES" will be recognized as a positive answer).
standard output
PASSED
9df89d11c5491bc8fde1c348287c1397
train_109.jsonl
1661871000
Timur likes his name. As a spelling of his name, he allows any permutation of the letters of the name. For example, the following strings are valid spellings of his name: Timur, miurT, Trumi, mriTu. Note that the correct spelling must have uppercased T and lowercased other letters.Today he wrote string $$$s$$$ of length $$$n$$$ consisting only of uppercase or lowercase Latin letters. He asks you to check if $$$s$$$ is the correct spelling of his name.
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.HashMap; import java.util.Map; public class problem1 { public boolean solve(int n, String s) { if (n != 5) return false; Map<Character, Integer> map = new HashMap<>(); for (char c : s.toCharArray()) map.put(c, map.getOrDefault(c, 0) + 1); Map<Character, Integer> name = new HashMap<>(); String realName = "Timur"; for (char c : realName.toCharArray()) { name.put(c, name.getOrDefault(c, 0) + 1); } for (Map.Entry<Character, Integer> entry : map.entrySet()) { if (name.get(entry.getKey()) != entry.getValue()) return false; } return true; } public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); problem1 solver = new problem1(); int t = Integer.parseInt(br.readLine()); while (t-- > 0) { int n = Integer.parseInt(br.readLine()); String s = br.readLine(); String res = solver.solve(n, s) ? "Yes" : "No"; System.out.println(res); } } }
Java
["10\n\n5\n\nTimur\n\n5\n\nmiurT\n\n5\n\nTrumi\n\n5\n\nmriTu\n\n5\n\ntimur\n\n4\n\nTimr\n\n6\n\nTimuur\n\n10\n\ncodeforces\n\n10\n\nTimurTimur\n\n5\n\nTIMUR"]
1 second
["YES\nYES\nYES\nYES\nNO\nNO\nNO\nNO\nNO\nNO"]
null
Java 17
standard input
[ "implementation" ]
6c137a74b36dede61037cb3b05167329
The first line of the input contains an integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The first line of each test case contains an integer $$$n$$$ $$$(1 \leq n \leq 10)$$$ — the length of string $$$s$$$. The second line of each test case contains a string $$$s$$$ consisting of only uppercase or lowercase Latin characters.
800
For each test case, output "YES" (without quotes) if $$$s$$$ satisfies the condition, and "NO" (without quotes) otherwise. You can output the answer in any case (for example, the strings "yEs", "yes", "Yes" and "YES" will be recognized as a positive answer).
standard output
PASSED
d385ccd92ad748ba6856519f87de8749
train_109.jsonl
1661871000
Timur likes his name. As a spelling of his name, he allows any permutation of the letters of the name. For example, the following strings are valid spellings of his name: Timur, miurT, Trumi, mriTu. Note that the correct spelling must have uppercased T and lowercased other letters.Today he wrote string $$$s$$$ of length $$$n$$$ consisting only of uppercase or lowercase Latin letters. He asks you to check if $$$s$$$ is the correct spelling of his name.
256 megabytes
import java.util.*; import java.io.*; public class Temp { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int t = sc.nextInt(); while (t > 0) { t--; int n = sc.nextInt(); String s; s = sc.next(); if (n != 5) { System.out.println("No"); continue; } else { Set<Character> set = new HashSet<>(); set.add('T'); set.add('i'); set.add('m'); set.add('u'); set.add('r'); int flag = 0; for (int i = 0; i < n; i++) { if(set.isEmpty() || !set.contains(s.charAt(i))) { System.out.println("NO"); flag = 1; break; } else{ set.remove(s.charAt(i)); } } if (flag == 0) System.out.println("yes"); } } } }
Java
["10\n\n5\n\nTimur\n\n5\n\nmiurT\n\n5\n\nTrumi\n\n5\n\nmriTu\n\n5\n\ntimur\n\n4\n\nTimr\n\n6\n\nTimuur\n\n10\n\ncodeforces\n\n10\n\nTimurTimur\n\n5\n\nTIMUR"]
1 second
["YES\nYES\nYES\nYES\nNO\nNO\nNO\nNO\nNO\nNO"]
null
Java 17
standard input
[ "implementation" ]
6c137a74b36dede61037cb3b05167329
The first line of the input contains an integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The first line of each test case contains an integer $$$n$$$ $$$(1 \leq n \leq 10)$$$ — the length of string $$$s$$$. The second line of each test case contains a string $$$s$$$ consisting of only uppercase or lowercase Latin characters.
800
For each test case, output "YES" (without quotes) if $$$s$$$ satisfies the condition, and "NO" (without quotes) otherwise. You can output the answer in any case (for example, the strings "yEs", "yes", "Yes" and "YES" will be recognized as a positive answer).
standard output
PASSED
7c67f44ce2284d9c8952280cf3df9938
train_109.jsonl
1661871000
Timur likes his name. As a spelling of his name, he allows any permutation of the letters of the name. For example, the following strings are valid spellings of his name: Timur, miurT, Trumi, mriTu. Note that the correct spelling must have uppercased T and lowercased other letters.Today he wrote string $$$s$$$ of length $$$n$$$ consisting only of uppercase or lowercase Latin letters. He asks you to check if $$$s$$$ is the correct spelling of his name.
256 megabytes
import java.util.*; public class solution{ public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); for(int i = 1; i <= n; i++){ int l = sc.nextInt(); String s = sc.next(); // String b = sc.next(); // boolean breaked = false; // for(int j = 0; j < l; j++){ // if(a.charAt(j) == 'R'){ // if(b.charAt(j) != 'R'){ // System.out.println("NO"); // breaked = true; // break; // } // }else if(b.charAt(j) == 'R'){ // System.out.println("NO"); // breaked = true; // break; // } // } // if(!breaked) System.out.println("YES"); if(l != 5){ System.out.println("NO"); continue; } int[] arr = new int[256]; for(int k = 0; k < s.length(); k++){ arr[s.charAt(k)] = 1; } boolean valid = true; String str = "Timur"; for(int k = 0; k < str.length(); k++){ if(arr[str.charAt(k)] != 1){ valid = false; break; } } if(valid) System.out.println("YES"); else System.out.println("No"); } } }
Java
["10\n\n5\n\nTimur\n\n5\n\nmiurT\n\n5\n\nTrumi\n\n5\n\nmriTu\n\n5\n\ntimur\n\n4\n\nTimr\n\n6\n\nTimuur\n\n10\n\ncodeforces\n\n10\n\nTimurTimur\n\n5\n\nTIMUR"]
1 second
["YES\nYES\nYES\nYES\nNO\nNO\nNO\nNO\nNO\nNO"]
null
Java 17
standard input
[ "implementation" ]
6c137a74b36dede61037cb3b05167329
The first line of the input contains an integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The first line of each test case contains an integer $$$n$$$ $$$(1 \leq n \leq 10)$$$ — the length of string $$$s$$$. The second line of each test case contains a string $$$s$$$ consisting of only uppercase or lowercase Latin characters.
800
For each test case, output "YES" (without quotes) if $$$s$$$ satisfies the condition, and "NO" (without quotes) otherwise. You can output the answer in any case (for example, the strings "yEs", "yes", "Yes" and "YES" will be recognized as a positive answer).
standard output
PASSED
bc706fadbf7afc6e0e29775ed13e33e3
train_109.jsonl
1661871000
Timur likes his name. As a spelling of his name, he allows any permutation of the letters of the name. For example, the following strings are valid spellings of his name: Timur, miurT, Trumi, mriTu. Note that the correct spelling must have uppercased T and lowercased other letters.Today he wrote string $$$s$$$ of length $$$n$$$ consisting only of uppercase or lowercase Latin letters. He asks you to check if $$$s$$$ is the correct spelling of his name.
256 megabytes
import java.util.*; import java.io.*; import java.lang.*; public class A_Spell_Check { public static final FastReader in = new FastReader(); public static final FastWriter out = new FastWriter(); public static void solve() throws Exception { /** Solution here */ var n = in.nextInt(); String s = in.next(); if (s.length() != 5) { out.println("NO"); } else{ int i = 0; int flag = 0; int TCount = 1; int iCount = 1; int mCount = 1; int uCount = 1; int rCount = 1; for (i = 0; i < s.length(); i++) { if (s.charAt(i) == 'T') { TCount--; } else if (s.charAt(i) == 'i') { iCount--; } else if (s.charAt(i) == 'm') { mCount--; } else if (s.charAt(i) == 'u') { uCount--; } else if (s.charAt(i) == 'r') { rCount--; } } if (TCount == iCount && iCount == mCount && mCount == uCount && uCount == rCount && rCount == 0) { out.println("YES"); } else { out.println("NO"); } } /** Don't change codes below */ } public static void main(String[] args) throws Exception { int t = in.nextInt(); while (t-- > 0) { solve(); } out.close(); } static class FastReader { BufferedReader br; StringTokenizer st; public FastReader() { br = new BufferedReader(new InputStreamReader(System.in)); } String next() { while (st == null || !st.hasMoreTokens()) { try { st = new StringTokenizer(br.readLine()); } catch (IOException e) { e.printStackTrace(); } } return st.nextToken(); } int nextInt() { return Integer.parseInt(next()); } long nextLong() { return Long.parseLong(next()); } double nextDouble() { return Double.parseDouble(next()); } String nextLine() { String str = ""; try { str = br.readLine().trim(); } catch (Exception e) { e.printStackTrace(); } return str; } } static class FastWriter { private final BufferedWriter bw; public FastWriter() { this.bw = new BufferedWriter(new OutputStreamWriter(System.out)); } public void print(Object object) throws IOException { bw.append("" + object); } public void println(Object object) throws IOException { print(object); bw.append("\n"); } public void close() throws IOException { bw.close(); } } }
Java
["10\n\n5\n\nTimur\n\n5\n\nmiurT\n\n5\n\nTrumi\n\n5\n\nmriTu\n\n5\n\ntimur\n\n4\n\nTimr\n\n6\n\nTimuur\n\n10\n\ncodeforces\n\n10\n\nTimurTimur\n\n5\n\nTIMUR"]
1 second
["YES\nYES\nYES\nYES\nNO\nNO\nNO\nNO\nNO\nNO"]
null
Java 17
standard input
[ "implementation" ]
6c137a74b36dede61037cb3b05167329
The first line of the input contains an integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The first line of each test case contains an integer $$$n$$$ $$$(1 \leq n \leq 10)$$$ — the length of string $$$s$$$. The second line of each test case contains a string $$$s$$$ consisting of only uppercase or lowercase Latin characters.
800
For each test case, output "YES" (without quotes) if $$$s$$$ satisfies the condition, and "NO" (without quotes) otherwise. You can output the answer in any case (for example, the strings "yEs", "yes", "Yes" and "YES" will be recognized as a positive answer).
standard output
PASSED
b67ead05cc44f52c2259ffed812b19e2
train_109.jsonl
1661871000
Timur likes his name. As a spelling of his name, he allows any permutation of the letters of the name. For example, the following strings are valid spellings of his name: Timur, miurT, Trumi, mriTu. Note that the correct spelling must have uppercased T and lowercased other letters.Today he wrote string $$$s$$$ of length $$$n$$$ consisting only of uppercase or lowercase Latin letters. He asks you to check if $$$s$$$ is the correct spelling of his name.
256 megabytes
import java.util.*; public class Main { public static void main(String[] args) { int t, n; String s; Scanner in = new Scanner(System.in); t = in.nextInt(); in.nextLine(); while (t-- > 0){ n = in.nextInt(); in.nextLine(); s = in.nextLine(); System.out.println(func(n, s)); } } private static String func(int n, String s){ if (n != 5) { return "NO"; } Map<Character, Integer> mp = new HashMap<>(); mp.put('T', 1); mp.put('i', 1); mp.put('m', 1); mp.put('u', 1); mp.put('r', 1); for (char c : s.toCharArray()) { mp.put(c, mp.getOrDefault(c, 0) - 1); } for (Map.Entry<Character, Integer> entry : mp.entrySet()) { Character k = entry.getKey(); Integer v = entry.getValue(); if (v != 0) { return "NO"; } } return "YES"; } }
Java
["10\n\n5\n\nTimur\n\n5\n\nmiurT\n\n5\n\nTrumi\n\n5\n\nmriTu\n\n5\n\ntimur\n\n4\n\nTimr\n\n6\n\nTimuur\n\n10\n\ncodeforces\n\n10\n\nTimurTimur\n\n5\n\nTIMUR"]
1 second
["YES\nYES\nYES\nYES\nNO\nNO\nNO\nNO\nNO\nNO"]
null
Java 17
standard input
[ "implementation" ]
6c137a74b36dede61037cb3b05167329
The first line of the input contains an integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The first line of each test case contains an integer $$$n$$$ $$$(1 \leq n \leq 10)$$$ — the length of string $$$s$$$. The second line of each test case contains a string $$$s$$$ consisting of only uppercase or lowercase Latin characters.
800
For each test case, output "YES" (without quotes) if $$$s$$$ satisfies the condition, and "NO" (without quotes) otherwise. You can output the answer in any case (for example, the strings "yEs", "yes", "Yes" and "YES" will be recognized as a positive answer).
standard output
PASSED
ccb16cc1a0119d7efe97b9589b912d58
train_109.jsonl
1661871000
Timur likes his name. As a spelling of his name, he allows any permutation of the letters of the name. For example, the following strings are valid spellings of his name: Timur, miurT, Trumi, mriTu. Note that the correct spelling must have uppercased T and lowercased other letters.Today he wrote string $$$s$$$ of length $$$n$$$ consisting only of uppercase or lowercase Latin letters. He asks you to check if $$$s$$$ is the correct spelling of his name.
256 megabytes
import java.util.Arrays; import java.util.Scanner; public class Problem1722 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int tc = sc.nextInt(); String s1 = "Timur"; char [] c = s1.toCharArray(); while(tc--> 0){ int n = sc.nextInt(); String s = sc.next(); char c1 [] = s.toCharArray(); Arrays.sort(c1); Arrays.sort(c); if(Arrays.equals(c1, c)){ System.out.println("Yes"); }else{ System.out.println("No"); } } } }
Java
["10\n\n5\n\nTimur\n\n5\n\nmiurT\n\n5\n\nTrumi\n\n5\n\nmriTu\n\n5\n\ntimur\n\n4\n\nTimr\n\n6\n\nTimuur\n\n10\n\ncodeforces\n\n10\n\nTimurTimur\n\n5\n\nTIMUR"]
1 second
["YES\nYES\nYES\nYES\nNO\nNO\nNO\nNO\nNO\nNO"]
null
Java 17
standard input
[ "implementation" ]
6c137a74b36dede61037cb3b05167329
The first line of the input contains an integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The first line of each test case contains an integer $$$n$$$ $$$(1 \leq n \leq 10)$$$ — the length of string $$$s$$$. The second line of each test case contains a string $$$s$$$ consisting of only uppercase or lowercase Latin characters.
800
For each test case, output "YES" (without quotes) if $$$s$$$ satisfies the condition, and "NO" (without quotes) otherwise. You can output the answer in any case (for example, the strings "yEs", "yes", "Yes" and "YES" will be recognized as a positive answer).
standard output
PASSED
2dcfbd6a8155a03f3b8442b3614e9c9d
train_109.jsonl
1661871000
Timur likes his name. As a spelling of his name, he allows any permutation of the letters of the name. For example, the following strings are valid spellings of his name: Timur, miurT, Trumi, mriTu. Note that the correct spelling must have uppercased T and lowercased other letters.Today he wrote string $$$s$$$ of length $$$n$$$ consisting only of uppercase or lowercase Latin letters. He asks you to check if $$$s$$$ is the correct spelling of his name.
256 megabytes
import java.util.Scanner; public class Problem1722 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int tc = sc.nextInt(); String s1 = "Timur"; while(tc--> 0){ int n = sc.nextInt(); String s = sc.next(); if(s.contains("T") && s.contains("m")&&s.contains("i")&&s.contains("u")&&s.contains("r")&&n==s1.length()){ System.out.println("Yes"); }else{ System.out.println("No"); } } } }
Java
["10\n\n5\n\nTimur\n\n5\n\nmiurT\n\n5\n\nTrumi\n\n5\n\nmriTu\n\n5\n\ntimur\n\n4\n\nTimr\n\n6\n\nTimuur\n\n10\n\ncodeforces\n\n10\n\nTimurTimur\n\n5\n\nTIMUR"]
1 second
["YES\nYES\nYES\nYES\nNO\nNO\nNO\nNO\nNO\nNO"]
null
Java 17
standard input
[ "implementation" ]
6c137a74b36dede61037cb3b05167329
The first line of the input contains an integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The first line of each test case contains an integer $$$n$$$ $$$(1 \leq n \leq 10)$$$ — the length of string $$$s$$$. The second line of each test case contains a string $$$s$$$ consisting of only uppercase or lowercase Latin characters.
800
For each test case, output "YES" (without quotes) if $$$s$$$ satisfies the condition, and "NO" (without quotes) otherwise. You can output the answer in any case (for example, the strings "yEs", "yes", "Yes" and "YES" will be recognized as a positive answer).
standard output
PASSED
e2d412c75a512d887ead9ad826cb568b
train_109.jsonl
1661871000
Timur likes his name. As a spelling of his name, he allows any permutation of the letters of the name. For example, the following strings are valid spellings of his name: Timur, miurT, Trumi, mriTu. Note that the correct spelling must have uppercased T and lowercased other letters.Today he wrote string $$$s$$$ of length $$$n$$$ consisting only of uppercase or lowercase Latin letters. He asks you to check if $$$s$$$ is the correct spelling of his name.
256 megabytes
import java.util.*; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int t = scanner.nextInt(); while(t>0){ int n = scanner.nextInt(); scanner.nextLine(); String s = scanner.nextLine(); char[] res = s.toCharArray(); Arrays.sort(res); String sortedString = new String(res); // System.out.println(sortedString); if(sortedString.equals("Timru")){ System.out.println("YES"); }else{ System.out.println("NO"); } t--; } scanner.close(); } }
Java
["10\n\n5\n\nTimur\n\n5\n\nmiurT\n\n5\n\nTrumi\n\n5\n\nmriTu\n\n5\n\ntimur\n\n4\n\nTimr\n\n6\n\nTimuur\n\n10\n\ncodeforces\n\n10\n\nTimurTimur\n\n5\n\nTIMUR"]
1 second
["YES\nYES\nYES\nYES\nNO\nNO\nNO\nNO\nNO\nNO"]
null
Java 17
standard input
[ "implementation" ]
6c137a74b36dede61037cb3b05167329
The first line of the input contains an integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The first line of each test case contains an integer $$$n$$$ $$$(1 \leq n \leq 10)$$$ — the length of string $$$s$$$. The second line of each test case contains a string $$$s$$$ consisting of only uppercase or lowercase Latin characters.
800
For each test case, output "YES" (without quotes) if $$$s$$$ satisfies the condition, and "NO" (without quotes) otherwise. You can output the answer in any case (for example, the strings "yEs", "yes", "Yes" and "YES" will be recognized as a positive answer).
standard output
PASSED
ac252655331af89fb5872576bbb38150
train_109.jsonl
1661871000
Timur likes his name. As a spelling of his name, he allows any permutation of the letters of the name. For example, the following strings are valid spellings of his name: Timur, miurT, Trumi, mriTu. Note that the correct spelling must have uppercased T and lowercased other letters.Today he wrote string $$$s$$$ of length $$$n$$$ consisting only of uppercase or lowercase Latin letters. He asks you to check if $$$s$$$ is the correct spelling of his name.
256 megabytes
import java.util.*; import java.lang.*; public class Main { public static void main (String[] args) throws java.lang.Exception { Scanner sc=new Scanner(System.in); int t=sc.nextInt(); for(int j=0;j<t;j++) { int n=sc.nextInt(); String s=sc.next(); if(n!=5) { System.out.println("NO"); } else { if(s.contains("T")&&s.contains("i")&&s.contains("m")&&s.contains("u")&&s.contains("r")) { System.out.println("YES"); } else { System.out.println("NO"); } } } } }
Java
["10\n\n5\n\nTimur\n\n5\n\nmiurT\n\n5\n\nTrumi\n\n5\n\nmriTu\n\n5\n\ntimur\n\n4\n\nTimr\n\n6\n\nTimuur\n\n10\n\ncodeforces\n\n10\n\nTimurTimur\n\n5\n\nTIMUR"]
1 second
["YES\nYES\nYES\nYES\nNO\nNO\nNO\nNO\nNO\nNO"]
null
Java 17
standard input
[ "implementation" ]
6c137a74b36dede61037cb3b05167329
The first line of the input contains an integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The first line of each test case contains an integer $$$n$$$ $$$(1 \leq n \leq 10)$$$ — the length of string $$$s$$$. The second line of each test case contains a string $$$s$$$ consisting of only uppercase or lowercase Latin characters.
800
For each test case, output "YES" (without quotes) if $$$s$$$ satisfies the condition, and "NO" (without quotes) otherwise. You can output the answer in any case (for example, the strings "yEs", "yes", "Yes" and "YES" will be recognized as a positive answer).
standard output
PASSED
162f4dd712192d59b8d31b56b4ce7977
train_109.jsonl
1661871000
Timur likes his name. As a spelling of his name, he allows any permutation of the letters of the name. For example, the following strings are valid spellings of his name: Timur, miurT, Trumi, mriTu. Note that the correct spelling must have uppercased T and lowercased other letters.Today he wrote string $$$s$$$ of length $$$n$$$ consisting only of uppercase or lowercase Latin letters. He asks you to check if $$$s$$$ is the correct spelling of his name.
256 megabytes
import java.io.*; import java.util.*; /* Author: heyharry Problem Statement: A */ public class Main { static class Reader { final private int BUFFER_SIZE = 1 << 16; private DataInputStream din; private byte[] buffer; private int bufferPointer, bytesRead; public Reader() { din = new DataInputStream(System.in); buffer = new byte[BUFFER_SIZE]; bufferPointer = bytesRead = 0; } public Reader(String file_name) throws IOException { din = new DataInputStream( new FileInputStream(file_name)); buffer = new byte[BUFFER_SIZE]; bufferPointer = bytesRead = 0; } public String readLine() throws IOException { byte[] buf = new byte[64]; // line length int cnt = 0, c; while ((c = read()) != -1) { if (c == '\n') { if (cnt != 0) { break; } else { continue; } } buf[cnt++] = (byte) c; } return new String(buf, 0, cnt); } public int nextInt() throws IOException { int ret = 0; byte c = read(); while (c <= ' ') { c = read(); } boolean neg = (c == '-'); if (neg) c = read(); do { ret = ret * 10 + c - '0'; } while ((c = read()) >= '0' && c <= '9'); if (neg) return -ret; return ret; } public long nextLong() throws IOException { long ret = 0; byte c = read(); while (c <= ' ') c = read(); boolean neg = (c == '-'); if (neg) c = read(); do { ret = ret * 10 + c - '0'; } while ((c = read()) >= '0' && c <= '9'); if (neg) return -ret; return ret; } public double nextDouble() throws IOException { double ret = 0, div = 1; byte c = read(); while (c <= ' ') c = read(); boolean neg = (c == '-'); if (neg) c = read(); do { ret = ret * 10 + c - '0'; } while ((c = read()) >= '0' && c <= '9'); if (c == '.') { while ((c = read()) >= '0' && c <= '9') { ret += (c - '0') / (div *= 10); } } if (neg) return -ret; return ret; } private void fillBuffer() throws IOException { bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE); if (bytesRead == -1) buffer[0] = -1; } private byte read() throws IOException { if (bufferPointer == bytesRead) fillBuffer(); return buffer[bufferPointer++]; } public void close() throws IOException { if (din == null) return; din.close(); } } public static void main(String[] args) throws IOException { Reader sc= new Reader(); long t=sc.nextLong(); while(t-->0){ long n=sc.nextLong(); StringTokenizer st= new StringTokenizer(sc.readLine()); String str=st.nextToken(); boolean flagA=false, flagB=false,flagC=false,flagD=false,flagE=false,flag=true ; for(int i=0; i<str.length(); i++){ if(str.charAt(i)=='T' ){ flagA=true; } else if(str.charAt(i)=='i'){ flagB=true; } else if(str.charAt(i)=='m'){ flagC=true; } else if(str.charAt(i)=='u'){ flagD=true; } else if(str.charAt(i)=='r'){ flagE=true; } else { flag=false; break; } } if(flag && flagA && flagB && flagC && flagD && flagE && str.length()==5) System.out.println("YES"); else System.out.println("NO"); } sc.close(); } }
Java
["10\n\n5\n\nTimur\n\n5\n\nmiurT\n\n5\n\nTrumi\n\n5\n\nmriTu\n\n5\n\ntimur\n\n4\n\nTimr\n\n6\n\nTimuur\n\n10\n\ncodeforces\n\n10\n\nTimurTimur\n\n5\n\nTIMUR"]
1 second
["YES\nYES\nYES\nYES\nNO\nNO\nNO\nNO\nNO\nNO"]
null
Java 17
standard input
[ "implementation" ]
6c137a74b36dede61037cb3b05167329
The first line of the input contains an integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The first line of each test case contains an integer $$$n$$$ $$$(1 \leq n \leq 10)$$$ — the length of string $$$s$$$. The second line of each test case contains a string $$$s$$$ consisting of only uppercase or lowercase Latin characters.
800
For each test case, output "YES" (without quotes) if $$$s$$$ satisfies the condition, and "NO" (without quotes) otherwise. You can output the answer in any case (for example, the strings "yEs", "yes", "Yes" and "YES" will be recognized as a positive answer).
standard output
PASSED
5bb16ac73c2205674de71a40b0a692aa
train_109.jsonl
1661871000
Timur likes his name. As a spelling of his name, he allows any permutation of the letters of the name. For example, the following strings are valid spellings of his name: Timur, miurT, Trumi, mriTu. Note that the correct spelling must have uppercased T and lowercased other letters.Today he wrote string $$$s$$$ of length $$$n$$$ consisting only of uppercase or lowercase Latin letters. He asks you to check if $$$s$$$ is the correct spelling of his name.
256 megabytes
import java.util.*; public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); int t = in.nextInt(); while (t-- > 0) { int n = in.nextInt(); String s = in.next(); HashSet<Character> set = new HashSet<>(); boolean os = false; for (int i = 0; i < s.length(); i++) { char ch = s.charAt(i); if (!isSame(ch) || set.contains(ch)) { System.out.println("NO"); os = true; break; } else { set.add(ch); } } if (!os){ if (set.size() == 5){ System.out.println("YES"); }else{ System.out.println("NO"); } } } } private static boolean isSame(char ch){ if (ch == 'T'|| ch == 'i' || ch == 'm' || ch == 'u'|| ch == 'r') return true; return false; } }
Java
["10\n\n5\n\nTimur\n\n5\n\nmiurT\n\n5\n\nTrumi\n\n5\n\nmriTu\n\n5\n\ntimur\n\n4\n\nTimr\n\n6\n\nTimuur\n\n10\n\ncodeforces\n\n10\n\nTimurTimur\n\n5\n\nTIMUR"]
1 second
["YES\nYES\nYES\nYES\nNO\nNO\nNO\nNO\nNO\nNO"]
null
Java 17
standard input
[ "implementation" ]
6c137a74b36dede61037cb3b05167329
The first line of the input contains an integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The first line of each test case contains an integer $$$n$$$ $$$(1 \leq n \leq 10)$$$ — the length of string $$$s$$$. The second line of each test case contains a string $$$s$$$ consisting of only uppercase or lowercase Latin characters.
800
For each test case, output "YES" (without quotes) if $$$s$$$ satisfies the condition, and "NO" (without quotes) otherwise. You can output the answer in any case (for example, the strings "yEs", "yes", "Yes" and "YES" will be recognized as a positive answer).
standard output
PASSED
a720e7f7a2486d3b7b2a591d5ef6bab0
train_109.jsonl
1661871000
Timur likes his name. As a spelling of his name, he allows any permutation of the letters of the name. For example, the following strings are valid spellings of his name: Timur, miurT, Trumi, mriTu. Note that the correct spelling must have uppercased T and lowercased other letters.Today he wrote string $$$s$$$ of length $$$n$$$ consisting only of uppercase or lowercase Latin letters. He asks you to check if $$$s$$$ is the correct spelling of his name.
256 megabytes
import java.util.*; import java.util.Arrays; public class Codeforce3{ public static String sortString(String inputString) { // Converting input string to character array char tempArray[] = inputString.toCharArray(); // Sorting temp array using Arrays.sort(tempArray); // Returning new sorted string return new String(tempArray); } public static void main(String args[]){ Scanner sc = new Scanner(System.in); int t = sc.nextInt(); while(t-->0){ int n = sc.nextInt(); String s = sc.next(); String fixs = "Timur"; String inputString =sortString(fixs); String outputString = sortString(s); if(outputString.equals(inputString)){ System.out.println("Yes"); } else{ System.out.println("No"); } } } }
Java
["10\n\n5\n\nTimur\n\n5\n\nmiurT\n\n5\n\nTrumi\n\n5\n\nmriTu\n\n5\n\ntimur\n\n4\n\nTimr\n\n6\n\nTimuur\n\n10\n\ncodeforces\n\n10\n\nTimurTimur\n\n5\n\nTIMUR"]
1 second
["YES\nYES\nYES\nYES\nNO\nNO\nNO\nNO\nNO\nNO"]
null
Java 17
standard input
[ "implementation" ]
6c137a74b36dede61037cb3b05167329
The first line of the input contains an integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The first line of each test case contains an integer $$$n$$$ $$$(1 \leq n \leq 10)$$$ — the length of string $$$s$$$. The second line of each test case contains a string $$$s$$$ consisting of only uppercase or lowercase Latin characters.
800
For each test case, output "YES" (without quotes) if $$$s$$$ satisfies the condition, and "NO" (without quotes) otherwise. You can output the answer in any case (for example, the strings "yEs", "yes", "Yes" and "YES" will be recognized as a positive answer).
standard output
PASSED
0cb64b82bfe4289cd141e64c1a32cb07
train_109.jsonl
1661871000
Timur likes his name. As a spelling of his name, he allows any permutation of the letters of the name. For example, the following strings are valid spellings of his name: Timur, miurT, Trumi, mriTu. Note that the correct spelling must have uppercased T and lowercased other letters.Today he wrote string $$$s$$$ of length $$$n$$$ consisting only of uppercase or lowercase Latin letters. He asks you to check if $$$s$$$ is the correct spelling of his name.
256 megabytes
import java.util.Arrays; import java.util.Scanner; public class Problem_1722A { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int t = sc.nextInt(); boolean[] ans = new boolean[t]; for (int i = 0; i < t; i++) { int n = sc.nextInt(); String str = sc.next(); StringBuilder st = new StringBuilder(); if(str.contains("T")){ st.append("T"); }if(str.contains("i")){ st.append("i"); }if(str.contains("m")){ st.append("m"); }if(str.contains("r")){ st.append("r"); }if(str.contains("u")){ st.append("u"); } ans[i] = (n == 5 && st.toString().equals("Timru")); } for(boolean e: ans) { if(e) System.out.println("YES"); else System.out.println("NO"); } } private static String sort(String s) { char[] temp = s.toCharArray(); Arrays.sort(temp); return temp.toString(); } }
Java
["10\n\n5\n\nTimur\n\n5\n\nmiurT\n\n5\n\nTrumi\n\n5\n\nmriTu\n\n5\n\ntimur\n\n4\n\nTimr\n\n6\n\nTimuur\n\n10\n\ncodeforces\n\n10\n\nTimurTimur\n\n5\n\nTIMUR"]
1 second
["YES\nYES\nYES\nYES\nNO\nNO\nNO\nNO\nNO\nNO"]
null
Java 17
standard input
[ "implementation" ]
6c137a74b36dede61037cb3b05167329
The first line of the input contains an integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The first line of each test case contains an integer $$$n$$$ $$$(1 \leq n \leq 10)$$$ — the length of string $$$s$$$. The second line of each test case contains a string $$$s$$$ consisting of only uppercase or lowercase Latin characters.
800
For each test case, output "YES" (without quotes) if $$$s$$$ satisfies the condition, and "NO" (without quotes) otherwise. You can output the answer in any case (for example, the strings "yEs", "yes", "Yes" and "YES" will be recognized as a positive answer).
standard output
PASSED
cf4ec163033c335dd5476ca593c2ce3e
train_109.jsonl
1661871000
Timur likes his name. As a spelling of his name, he allows any permutation of the letters of the name. For example, the following strings are valid spellings of his name: Timur, miurT, Trumi, mriTu. Note that the correct spelling must have uppercased T and lowercased other letters.Today he wrote string $$$s$$$ of length $$$n$$$ consisting only of uppercase or lowercase Latin letters. He asks you to check if $$$s$$$ is the correct spelling of his name.
256 megabytes
/** * A_Spell_Check */ import java.util.*; public class A_Spell_Check { public static void main(String[] args) { Scanner inp = new Scanner(System.in); int t = inp.nextInt(); while(t-- > 0){ inp.nextInt(); String str1 = inp.next(); char[] arr = str1.toCharArray(); Arrays.sort(arr); str1 = new String(arr); String str5 = "Timru"; // imrTu // String s = ""; // System.out.println(str1 + " " + str5); // System.out.println(str1 + " " + str2 + " " + str3 + " " + str4 +" "+ str5); // System.out.println(str1.getClass() + " " + str2.getClass()); if(str1.equals(str5)){ System.out.println("YES"); } else{ System.out.println("NO"); } } inp.close(); } }
Java
["10\n\n5\n\nTimur\n\n5\n\nmiurT\n\n5\n\nTrumi\n\n5\n\nmriTu\n\n5\n\ntimur\n\n4\n\nTimr\n\n6\n\nTimuur\n\n10\n\ncodeforces\n\n10\n\nTimurTimur\n\n5\n\nTIMUR"]
1 second
["YES\nYES\nYES\nYES\nNO\nNO\nNO\nNO\nNO\nNO"]
null
Java 17
standard input
[ "implementation" ]
6c137a74b36dede61037cb3b05167329
The first line of the input contains an integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The first line of each test case contains an integer $$$n$$$ $$$(1 \leq n \leq 10)$$$ — the length of string $$$s$$$. The second line of each test case contains a string $$$s$$$ consisting of only uppercase or lowercase Latin characters.
800
For each test case, output "YES" (without quotes) if $$$s$$$ satisfies the condition, and "NO" (without quotes) otherwise. You can output the answer in any case (for example, the strings "yEs", "yes", "Yes" and "YES" will be recognized as a positive answer).
standard output
PASSED
ac028d9226a132fd0c0d84a23b17d359
train_109.jsonl
1661871000
Timur likes his name. As a spelling of his name, he allows any permutation of the letters of the name. For example, the following strings are valid spellings of his name: Timur, miurT, Trumi, mriTu. Note that the correct spelling must have uppercased T and lowercased other letters.Today he wrote string $$$s$$$ of length $$$n$$$ consisting only of uppercase or lowercase Latin letters. He asks you to check if $$$s$$$ is the correct spelling of his name.
256 megabytes
import java.util.HashSet; import java.io.BufferedReader; import java.io.BufferedOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.io.OutputStream; import java.util.StringTokenizer; public class SpellCheck { public static HashSet<Character> set = new HashSet<>(); static void initSet() { set.add('T'); set.add('i'); set.add('m'); set.add('u'); set.add('r'); } public static void main(String[] args) { Kattio inp = new Kattio(System.in); int T = inp.getInt(); initSet(); for (int i = 0; i < T; i++) { int siz = inp.getInt(); String st = inp.getWord(); if (siz < 5 || siz > 5) inp.println("NO"); else { for (int d = 0; d < 5; d++) { if (set.contains(st.charAt(d))) { set.remove(st.charAt(d)); } } if (set.size() == 0) { inp.println("YES"); } else inp.println("NO"); set.clear(); initSet(); } } inp.flush(); inp.close(); } } class Kattio extends PrintWriter { public Kattio(InputStream i) { super(new BufferedOutputStream(System.out)); r = new BufferedReader(new InputStreamReader(i)); } public Kattio(InputStream i, OutputStream o) { super(new BufferedOutputStream(o)); r = new BufferedReader(new InputStreamReader(i)); } public boolean hasMoreTokens() { return peekToken() != null; } public int getInt() { return Integer.parseInt(nextToken()); } public double getDouble() { return Double.parseDouble(nextToken()); } public long getLong() { return Long.parseLong(nextToken()); } public String getWord() { return nextToken(); } private BufferedReader r; private String line; private StringTokenizer st; private String token; private String peekToken() { if (token == null) try { while (st == null || !st.hasMoreTokens()) { line = r.readLine(); if (line == null) return null; st = new StringTokenizer(line); } token = st.nextToken(); } catch (IOException e) { } return token; } private String nextToken() { String ans = peekToken(); token = null; return ans; } }
Java
["10\n\n5\n\nTimur\n\n5\n\nmiurT\n\n5\n\nTrumi\n\n5\n\nmriTu\n\n5\n\ntimur\n\n4\n\nTimr\n\n6\n\nTimuur\n\n10\n\ncodeforces\n\n10\n\nTimurTimur\n\n5\n\nTIMUR"]
1 second
["YES\nYES\nYES\nYES\nNO\nNO\nNO\nNO\nNO\nNO"]
null
Java 17
standard input
[ "implementation" ]
6c137a74b36dede61037cb3b05167329
The first line of the input contains an integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The first line of each test case contains an integer $$$n$$$ $$$(1 \leq n \leq 10)$$$ — the length of string $$$s$$$. The second line of each test case contains a string $$$s$$$ consisting of only uppercase or lowercase Latin characters.
800
For each test case, output "YES" (without quotes) if $$$s$$$ satisfies the condition, and "NO" (without quotes) otherwise. You can output the answer in any case (for example, the strings "yEs", "yes", "Yes" and "YES" will be recognized as a positive answer).
standard output
PASSED
c9aacf5dab6e07eaeb1dac1292086ea4
train_109.jsonl
1661871000
Timur likes his name. As a spelling of his name, he allows any permutation of the letters of the name. For example, the following strings are valid spellings of his name: Timur, miurT, Trumi, mriTu. Note that the correct spelling must have uppercased T and lowercased other letters.Today he wrote string $$$s$$$ of length $$$n$$$ consisting only of uppercase or lowercase Latin letters. He asks you to check if $$$s$$$ is the correct spelling of his name.
256 megabytes
import java.util.*; public class R817A { public static String solve(int len, String s) { if(len != 5) return "NO"; int[] cnt = new int[256]; for(int i = 0; i < s.length(); i++) { cnt[s.charAt(i)]++; } //Timur if(cnt['T'] == 1 && cnt['i'] == 1 && cnt['m'] == 1 && cnt['u'] == 1 && cnt['r'] == 1) { return "YES"; } return "NO"; } public static void main(String[] args) { Scanner in = new Scanner(System.in); int t = in.nextInt(); in.nextLine(); for(int i = 0; i < t; i++) { int len = in.nextInt(); in.nextLine(); String s = in.nextLine(); System.out.println(solve(len, s)); System.out.flush(); } } }
Java
["10\n\n5\n\nTimur\n\n5\n\nmiurT\n\n5\n\nTrumi\n\n5\n\nmriTu\n\n5\n\ntimur\n\n4\n\nTimr\n\n6\n\nTimuur\n\n10\n\ncodeforces\n\n10\n\nTimurTimur\n\n5\n\nTIMUR"]
1 second
["YES\nYES\nYES\nYES\nNO\nNO\nNO\nNO\nNO\nNO"]
null
Java 17
standard input
[ "implementation" ]
6c137a74b36dede61037cb3b05167329
The first line of the input contains an integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The first line of each test case contains an integer $$$n$$$ $$$(1 \leq n \leq 10)$$$ — the length of string $$$s$$$. The second line of each test case contains a string $$$s$$$ consisting of only uppercase or lowercase Latin characters.
800
For each test case, output "YES" (without quotes) if $$$s$$$ satisfies the condition, and "NO" (without quotes) otherwise. You can output the answer in any case (for example, the strings "yEs", "yes", "Yes" and "YES" will be recognized as a positive answer).
standard output
PASSED
7ff0ed207bef016a2abc1bd621b68314
train_109.jsonl
1661871000
Timur likes his name. As a spelling of his name, he allows any permutation of the letters of the name. For example, the following strings are valid spellings of his name: Timur, miurT, Trumi, mriTu. Note that the correct spelling must have uppercased T and lowercased other letters.Today he wrote string $$$s$$$ of length $$$n$$$ consisting only of uppercase or lowercase Latin letters. He asks you to check if $$$s$$$ is the correct spelling of his name.
256 megabytes
import java.util.Scanner; public class Practice { public static void main(String[] args) { Scanner read = new Scanner(System.in); String x = "Timur"; int[] freqOriginal = new int[27]; for (int i = 0; i < x.length(); i++) { if (x.charAt(i) == 84) { freqOriginal[0]++; continue; } freqOriginal[x.charAt(i) - 'a']++; } int t = read.nextInt(); while (t > 0) { int n = read.nextInt(); String name = read.next(); System.out.println(answer(n, name, freqOriginal)); t--; } } static String answer (int n, String name, int[] freqOriginal) { if (n != 5) return "NO"; for (int i = 0; i < name.length(); i++) { if (name.charAt(i) != 84 && (name.charAt(i) < 97 || name.charAt(i) > 122)) return "NO"; } int[] freqNew = new int[27]; for (int i = 0; i < 5; i++) { if (name.charAt(i) == 84) { freqNew[0]++; continue; } freqNew[name.charAt(i) - 'a']++; } for (int i = 0; i < freqNew.length; i++) { if (freqNew[i] != freqOriginal[i]) return "NO"; } return "YES"; } }
Java
["10\n\n5\n\nTimur\n\n5\n\nmiurT\n\n5\n\nTrumi\n\n5\n\nmriTu\n\n5\n\ntimur\n\n4\n\nTimr\n\n6\n\nTimuur\n\n10\n\ncodeforces\n\n10\n\nTimurTimur\n\n5\n\nTIMUR"]
1 second
["YES\nYES\nYES\nYES\nNO\nNO\nNO\nNO\nNO\nNO"]
null
Java 17
standard input
[ "implementation" ]
6c137a74b36dede61037cb3b05167329
The first line of the input contains an integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The first line of each test case contains an integer $$$n$$$ $$$(1 \leq n \leq 10)$$$ — the length of string $$$s$$$. The second line of each test case contains a string $$$s$$$ consisting of only uppercase or lowercase Latin characters.
800
For each test case, output "YES" (without quotes) if $$$s$$$ satisfies the condition, and "NO" (without quotes) otherwise. You can output the answer in any case (for example, the strings "yEs", "yes", "Yes" and "YES" will be recognized as a positive answer).
standard output
PASSED
dabc24bd491582e65a9e571efe62858a
train_109.jsonl
1661871000
Timur likes his name. As a spelling of his name, he allows any permutation of the letters of the name. For example, the following strings are valid spellings of his name: Timur, miurT, Trumi, mriTu. Note that the correct spelling must have uppercased T and lowercased other letters.Today he wrote string $$$s$$$ of length $$$n$$$ consisting only of uppercase or lowercase Latin letters. He asks you to check if $$$s$$$ is the correct spelling of his name.
256 megabytes
import java.util.Scanner; import java.util.Set; import java.util.HashSet; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int t = sc.nextInt(); while(t-- > 0){ int len = sc.nextInt(); String str = sc.next(); if(len <= 5){ Set<Character> set = new HashSet<>(); for(int i=0;i<str.length();i++){ char ch = str.charAt(i); if( ch == 'T' || ch == 'i' || ch == 'm' || ch == 'u' || ch == 'r') set.add(ch); } if(set.size() == 5) System.out.println("YES"); else System.out.println("NO"); } else System.out.println("NO"); } } }
Java
["10\n\n5\n\nTimur\n\n5\n\nmiurT\n\n5\n\nTrumi\n\n5\n\nmriTu\n\n5\n\ntimur\n\n4\n\nTimr\n\n6\n\nTimuur\n\n10\n\ncodeforces\n\n10\n\nTimurTimur\n\n5\n\nTIMUR"]
1 second
["YES\nYES\nYES\nYES\nNO\nNO\nNO\nNO\nNO\nNO"]
null
Java 17
standard input
[ "implementation" ]
6c137a74b36dede61037cb3b05167329
The first line of the input contains an integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The first line of each test case contains an integer $$$n$$$ $$$(1 \leq n \leq 10)$$$ — the length of string $$$s$$$. The second line of each test case contains a string $$$s$$$ consisting of only uppercase or lowercase Latin characters.
800
For each test case, output "YES" (without quotes) if $$$s$$$ satisfies the condition, and "NO" (without quotes) otherwise. You can output the answer in any case (for example, the strings "yEs", "yes", "Yes" and "YES" will be recognized as a positive answer).
standard output
PASSED
95863b6939a34932374bfa2bb89f663f
train_109.jsonl
1661871000
Timur likes his name. As a spelling of his name, he allows any permutation of the letters of the name. For example, the following strings are valid spellings of his name: Timur, miurT, Trumi, mriTu. Note that the correct spelling must have uppercased T and lowercased other letters.Today he wrote string $$$s$$$ of length $$$n$$$ consisting only of uppercase or lowercase Latin letters. He asks you to check if $$$s$$$ is the correct spelling of his name.
256 megabytes
import java.util.*; public class codeforces { static String sortString(String s){ char tempArray[] = s.toCharArray(); Arrays.sort(tempArray); return new String(tempArray); } public static void main(String[] args) { Scanner sc = new Scanner(System.in); int t = sc.nextInt(); while(t-->0){ int n = sc.nextInt(); String s = sc.next(); String s1 = "Timur"; String s2 = sortString(s); String s3 = sortString(s1); int a = s2.compareTo(s3); if(n!=5){ System.out.println("NO"); } else{ if(a==0){ System.out.println("YES"); } else{ System.out.println("NO"); } } } } }
Java
["10\n\n5\n\nTimur\n\n5\n\nmiurT\n\n5\n\nTrumi\n\n5\n\nmriTu\n\n5\n\ntimur\n\n4\n\nTimr\n\n6\n\nTimuur\n\n10\n\ncodeforces\n\n10\n\nTimurTimur\n\n5\n\nTIMUR"]
1 second
["YES\nYES\nYES\nYES\nNO\nNO\nNO\nNO\nNO\nNO"]
null
Java 17
standard input
[ "implementation" ]
6c137a74b36dede61037cb3b05167329
The first line of the input contains an integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The first line of each test case contains an integer $$$n$$$ $$$(1 \leq n \leq 10)$$$ — the length of string $$$s$$$. The second line of each test case contains a string $$$s$$$ consisting of only uppercase or lowercase Latin characters.
800
For each test case, output "YES" (without quotes) if $$$s$$$ satisfies the condition, and "NO" (without quotes) otherwise. You can output the answer in any case (for example, the strings "yEs", "yes", "Yes" and "YES" will be recognized as a positive answer).
standard output
PASSED
2c6340bee7c1740eeff14e22cb33a1e1
train_109.jsonl
1661871000
Timur likes his name. As a spelling of his name, he allows any permutation of the letters of the name. For example, the following strings are valid spellings of his name: Timur, miurT, Trumi, mriTu. Note that the correct spelling must have uppercased T and lowercased other letters.Today he wrote string $$$s$$$ of length $$$n$$$ consisting only of uppercase or lowercase Latin letters. He asks you to check if $$$s$$$ is the correct spelling of his name.
256 megabytes
import java.util.Arrays; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int testCases = sc.nextInt(); for (int i = 0; i < testCases; i++) { int tamaño = sc.nextInt(); String nombre = sc.next(); char [] temp = nombre.toCharArray(); Arrays.sort(temp); String organizado = new String (temp); ; if(organizado.contains("Timru") && tamaño==5){ System.out.println("YES"); }else System.out.println("NO"); } } }
Java
["10\n\n5\n\nTimur\n\n5\n\nmiurT\n\n5\n\nTrumi\n\n5\n\nmriTu\n\n5\n\ntimur\n\n4\n\nTimr\n\n6\n\nTimuur\n\n10\n\ncodeforces\n\n10\n\nTimurTimur\n\n5\n\nTIMUR"]
1 second
["YES\nYES\nYES\nYES\nNO\nNO\nNO\nNO\nNO\nNO"]
null
Java 17
standard input
[ "implementation" ]
6c137a74b36dede61037cb3b05167329
The first line of the input contains an integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The first line of each test case contains an integer $$$n$$$ $$$(1 \leq n \leq 10)$$$ — the length of string $$$s$$$. The second line of each test case contains a string $$$s$$$ consisting of only uppercase or lowercase Latin characters.
800
For each test case, output "YES" (without quotes) if $$$s$$$ satisfies the condition, and "NO" (without quotes) otherwise. You can output the answer in any case (for example, the strings "yEs", "yes", "Yes" and "YES" will be recognized as a positive answer).
standard output
PASSED
88da1fe90bf1334c43604c40c81bcb25
train_109.jsonl
1661871000
Timur likes his name. As a spelling of his name, he allows any permutation of the letters of the name. For example, the following strings are valid spellings of his name: Timur, miurT, Trumi, mriTu. Note that the correct spelling must have uppercased T and lowercased other letters.Today he wrote string $$$s$$$ of length $$$n$$$ consisting only of uppercase or lowercase Latin letters. He asks you to check if $$$s$$$ is the correct spelling of his name.
256 megabytes
import java.util.Arrays; import java.util.Scanner; /* The pain you feel today will be the strength you feel tomorrow */ public class Bb { public static void main(String[] args) { Scanner in = new Scanner(System.in); int t = in.nextInt(); for (int z = 0; z < t; z++) { boolean f = true; int n = in.nextInt(); String s = in.next(); String test = "Timur"; char arr[] = test.toCharArray(); char arrr[] = s.toCharArray(); Arrays.sort(arr); Arrays.sort(arrr); if (arr.length != arrr.length) { System.out.println("NO"); } else { for (int i = 0; i < arr.length; i++) { if (arr[i] != arrr[i]) { f = false; break; } } if (f) { System.out.println("YES"); } else { System.out.println("NO"); } } } } }
Java
["10\n\n5\n\nTimur\n\n5\n\nmiurT\n\n5\n\nTrumi\n\n5\n\nmriTu\n\n5\n\ntimur\n\n4\n\nTimr\n\n6\n\nTimuur\n\n10\n\ncodeforces\n\n10\n\nTimurTimur\n\n5\n\nTIMUR"]
1 second
["YES\nYES\nYES\nYES\nNO\nNO\nNO\nNO\nNO\nNO"]
null
Java 17
standard input
[ "implementation" ]
6c137a74b36dede61037cb3b05167329
The first line of the input contains an integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The first line of each test case contains an integer $$$n$$$ $$$(1 \leq n \leq 10)$$$ — the length of string $$$s$$$. The second line of each test case contains a string $$$s$$$ consisting of only uppercase or lowercase Latin characters.
800
For each test case, output "YES" (without quotes) if $$$s$$$ satisfies the condition, and "NO" (without quotes) otherwise. You can output the answer in any case (for example, the strings "yEs", "yes", "Yes" and "YES" will be recognized as a positive answer).
standard output
PASSED
1768cbe2ed9d09553edd81192736ea98
train_109.jsonl
1661871000
Timur likes his name. As a spelling of his name, he allows any permutation of the letters of the name. For example, the following strings are valid spellings of his name: Timur, miurT, Trumi, mriTu. Note that the correct spelling must have uppercased T and lowercased other letters.Today he wrote string $$$s$$$ of length $$$n$$$ consisting only of uppercase or lowercase Latin letters. He asks you to check if $$$s$$$ is the correct spelling of his name.
256 megabytes
import java.util.Scanner; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = Integer.parseInt(in.nextLine()); for (int i = 0; i < n; i++) { int h = Integer.parseInt(in.nextLine()); String word = in.nextLine(); ArrayList wordParts = new ArrayList(Arrays.asList(word.split(""))); ArrayList wordC = new ArrayList(Arrays.asList("Timur".split(""))); Collections.sort(wordC); Collections.sort(wordParts); if (wordParts.equals(wordC)) { System.out.println("YES"); } else { System.out.println("NO"); } } } }
Java
["10\n\n5\n\nTimur\n\n5\n\nmiurT\n\n5\n\nTrumi\n\n5\n\nmriTu\n\n5\n\ntimur\n\n4\n\nTimr\n\n6\n\nTimuur\n\n10\n\ncodeforces\n\n10\n\nTimurTimur\n\n5\n\nTIMUR"]
1 second
["YES\nYES\nYES\nYES\nNO\nNO\nNO\nNO\nNO\nNO"]
null
Java 17
standard input
[ "implementation" ]
6c137a74b36dede61037cb3b05167329
The first line of the input contains an integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The first line of each test case contains an integer $$$n$$$ $$$(1 \leq n \leq 10)$$$ — the length of string $$$s$$$. The second line of each test case contains a string $$$s$$$ consisting of only uppercase or lowercase Latin characters.
800
For each test case, output "YES" (without quotes) if $$$s$$$ satisfies the condition, and "NO" (without quotes) otherwise. You can output the answer in any case (for example, the strings "yEs", "yes", "Yes" and "YES" will be recognized as a positive answer).
standard output
PASSED
42e1049b5cf39a4ec42ca53cad7c7000
train_109.jsonl
1661871000
Timur likes his name. As a spelling of his name, he allows any permutation of the letters of the name. For example, the following strings are valid spellings of his name: Timur, miurT, Trumi, mriTu. Note that the correct spelling must have uppercased T and lowercased other letters.Today he wrote string $$$s$$$ of length $$$n$$$ consisting only of uppercase or lowercase Latin letters. He asks you to check if $$$s$$$ is the correct spelling of his name.
256 megabytes
import java.util.*; public class mm { static Scanner s = new Scanner(System.in); public static void main(String[] args) { int n=s.nextInt(); while(n-->0){ int nn =s.nextInt(); String ss = s.next(); if(nn != 5){ System.out.println("NO"); }else{ ArrayList<Character> ch = new ArrayList<>(Arrays.asList('T','i','m','u','r')); ArrayList<Character> chh = new ArrayList<>(); int count=0; for(int i=0;i<ss.length();i++){ chh.add(ss.charAt(i)); } ch.removeAll(chh); if(ch.size()==0){ System.out.println("YES"); }else{ System.out.println("NO"); } } } } }
Java
["10\n\n5\n\nTimur\n\n5\n\nmiurT\n\n5\n\nTrumi\n\n5\n\nmriTu\n\n5\n\ntimur\n\n4\n\nTimr\n\n6\n\nTimuur\n\n10\n\ncodeforces\n\n10\n\nTimurTimur\n\n5\n\nTIMUR"]
1 second
["YES\nYES\nYES\nYES\nNO\nNO\nNO\nNO\nNO\nNO"]
null
Java 17
standard input
[ "implementation" ]
6c137a74b36dede61037cb3b05167329
The first line of the input contains an integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The first line of each test case contains an integer $$$n$$$ $$$(1 \leq n \leq 10)$$$ — the length of string $$$s$$$. The second line of each test case contains a string $$$s$$$ consisting of only uppercase or lowercase Latin characters.
800
For each test case, output "YES" (without quotes) if $$$s$$$ satisfies the condition, and "NO" (without quotes) otherwise. You can output the answer in any case (for example, the strings "yEs", "yes", "Yes" and "YES" will be recognized as a positive answer).
standard output
PASSED
5722549aa4d2eba14dff5cfbf511b473
train_109.jsonl
1661871000
Timur likes his name. As a spelling of his name, he allows any permutation of the letters of the name. For example, the following strings are valid spellings of his name: Timur, miurT, Trumi, mriTu. Note that the correct spelling must have uppercased T and lowercased other letters.Today he wrote string $$$s$$$ of length $$$n$$$ consisting only of uppercase or lowercase Latin letters. He asks you to check if $$$s$$$ is the correct spelling of his name.
256 megabytes
import java.util.*; public class test{ public static void main(String[] s) { Scanner sc = new Scanner(System.in); // System.out.print("Enter the number of elements of the array:"); char[] arr2 = new char[]{'T','i','m','u','r'}; Arrays.sort(arr2); int t = sc.nextInt(); while(t>0){ int n = sc.nextInt(); sc.nextLine(); char[] arr = sc.next().toCharArray(); if(n>5 || n<5) { System.out.println("NO"); } else{ Arrays.sort(arr); boolean b = Arrays.equals(arr2, arr); if(b) System.out.println("YES"); else System.out.println("NO"); } t--; } sc.close(); } }
Java
["10\n\n5\n\nTimur\n\n5\n\nmiurT\n\n5\n\nTrumi\n\n5\n\nmriTu\n\n5\n\ntimur\n\n4\n\nTimr\n\n6\n\nTimuur\n\n10\n\ncodeforces\n\n10\n\nTimurTimur\n\n5\n\nTIMUR"]
1 second
["YES\nYES\nYES\nYES\nNO\nNO\nNO\nNO\nNO\nNO"]
null
Java 17
standard input
[ "implementation" ]
6c137a74b36dede61037cb3b05167329
The first line of the input contains an integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The first line of each test case contains an integer $$$n$$$ $$$(1 \leq n \leq 10)$$$ — the length of string $$$s$$$. The second line of each test case contains a string $$$s$$$ consisting of only uppercase or lowercase Latin characters.
800
For each test case, output "YES" (without quotes) if $$$s$$$ satisfies the condition, and "NO" (without quotes) otherwise. You can output the answer in any case (for example, the strings "yEs", "yes", "Yes" and "YES" will be recognized as a positive answer).
standard output
PASSED
ac1570d503cc91413d323fecbf062589
train_109.jsonl
1661871000
Timur likes his name. As a spelling of his name, he allows any permutation of the letters of the name. For example, the following strings are valid spellings of his name: Timur, miurT, Trumi, mriTu. Note that the correct spelling must have uppercased T and lowercased other letters.Today he wrote string $$$s$$$ of length $$$n$$$ consisting only of uppercase or lowercase Latin letters. He asks you to check if $$$s$$$ is the correct spelling of his name.
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Arrays; import java.util.HashSet; import java.util.Set; public class Main { static BufferedReader reader; static Set<String> chars; public static void main(String[] args) throws IOException { reader = new BufferedReader(new InputStreamReader(System.in)); chars = new HashSet<>(Arrays.asList("T", "i", "m", "u", "r")); int count = Integer.parseInt(reader.readLine()); for (int i = 0; i < count; i++) { int length = Integer.parseInt(reader.readLine()); String input = reader.readLine(); if (length != 5) { System.out.println("NO"); continue; } Set<String> tempSet = new HashSet<>(chars); for (int j = 0; j < length; j++) { String c = input.substring(j, j + 1); if (!tempSet.contains(c)) { System.out.println("NO"); j = length; } tempSet.remove(c); if (j == length - 1) { System.out.println("YES"); } } } } }
Java
["10\n\n5\n\nTimur\n\n5\n\nmiurT\n\n5\n\nTrumi\n\n5\n\nmriTu\n\n5\n\ntimur\n\n4\n\nTimr\n\n6\n\nTimuur\n\n10\n\ncodeforces\n\n10\n\nTimurTimur\n\n5\n\nTIMUR"]
1 second
["YES\nYES\nYES\nYES\nNO\nNO\nNO\nNO\nNO\nNO"]
null
Java 17
standard input
[ "implementation" ]
6c137a74b36dede61037cb3b05167329
The first line of the input contains an integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The first line of each test case contains an integer $$$n$$$ $$$(1 \leq n \leq 10)$$$ — the length of string $$$s$$$. The second line of each test case contains a string $$$s$$$ consisting of only uppercase or lowercase Latin characters.
800
For each test case, output "YES" (without quotes) if $$$s$$$ satisfies the condition, and "NO" (without quotes) otherwise. You can output the answer in any case (for example, the strings "yEs", "yes", "Yes" and "YES" will be recognized as a positive answer).
standard output