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
5aa8fb77af35dfc8aee14fa47e366c18
train_002.jsonl
1538750100
Vasya has recently got a job as a cashier at a local store. His day at work is $$$L$$$ minutes long. Vasya has already memorized $$$n$$$ regular customers, the $$$i$$$-th of which comes after $$$t_{i}$$$ minutes after the beginning of the day, and his service consumes $$$l_{i}$$$ minutes. It is guaranteed that no customer will arrive while Vasya is servicing another customer. Vasya is a bit lazy, so he likes taking smoke breaks for $$$a$$$ minutes each. Those breaks may go one after another, but Vasya must be present at work during all the time periods he must serve regular customers, otherwise one of them may alert his boss. What is the maximum number of breaks Vasya can take during the day?
256 megabytes
import java.util.*; public class Cash { public static void main(String[] args) { Scanner sc=new Scanner(System.in); int L=0,n=0,a=0; n=sc.nextInt(); L=sc.nextInt(); a=sc.nextInt(); int i=0; int k=0; int ti[]=new int[n]; int li[]=new int[n]; int te=0,sum=0; for(i=0;i<n;i++) { ti[k]=sc.nextInt(); li[k]=sc.nextInt(); sum=sum+(ti[k]-te)/a; te=li[k]+ti[k]; // System.out.println("fad "+te); k=k+1; } // i=0; //while(i<n) //{ //} //System.out.println("i is "+i+"and te is "+te); sum=sum+(L-te)/a; System.out.println(sum); } }
Java
["2 11 3\n0 1\n1 1", "0 5 2", "1 3 2\n1 2"]
2 seconds
["3", "2", "0"]
NoteIn the first sample Vasya can take $$$3$$$ breaks starting after $$$2$$$, $$$5$$$ and $$$8$$$ minutes after the beginning of the day.In the second sample Vasya can take $$$2$$$ breaks starting after $$$0$$$ and $$$2$$$ minutes after the beginning of the day.In the third sample Vasya can't take any breaks.
Java 8
standard input
[ "implementation" ]
00acb3b54975820989a788b9389c7c0b
The first line contains three integers $$$n$$$, $$$L$$$ and $$$a$$$ ($$$0 \le n \le 10^{5}$$$, $$$1 \le L \le 10^{9}$$$, $$$1 \le a \le L$$$). The $$$i$$$-th of the next $$$n$$$ lines contains two integers $$$t_{i}$$$ and $$$l_{i}$$$ ($$$0 \le t_{i} \le L - 1$$$, $$$1 \le l_{i} \le L$$$). It is guaranteed that $$$t_{i} + l_{i} \le t_{i + 1}$$$ and $$$t_{n} + l_{n} \le L$$$.
1,000
Output one integer  — the maximum number of breaks.
standard output
PASSED
9f68bd139eccd414df679ecb0d10e507
train_002.jsonl
1538750100
Vasya has recently got a job as a cashier at a local store. His day at work is $$$L$$$ minutes long. Vasya has already memorized $$$n$$$ regular customers, the $$$i$$$-th of which comes after $$$t_{i}$$$ minutes after the beginning of the day, and his service consumes $$$l_{i}$$$ minutes. It is guaranteed that no customer will arrive while Vasya is servicing another customer. Vasya is a bit lazy, so he likes taking smoke breaks for $$$a$$$ minutes each. Those breaks may go one after another, but Vasya must be present at work during all the time periods he must serve regular customers, otherwise one of them may alert his boss. What is the maximum number of breaks Vasya can take during the day?
256 megabytes
import java.util.*; public class Cash { public static void main(String[] args) { Scanner sc=new Scanner(System.in); int L=0,n=0,a=0; n=sc.nextInt(); L=sc.nextInt(); a=sc.nextInt(); int i=0; int ti[]=new int[n]; int li[]=new int[n]; int te=0,sum=0; for(i=0;i<n;i++) { ti[i]=sc.nextInt(); li[i]=sc.nextInt(); } i=0; while(i<n) { sum=sum+(ti[i]-te)/a; te=li[i]+ti[i]; // System.out.println("fad "+te); i=i+1; } //System.out.println("i is "+i+"and te is "+te); sum=sum+(L-te)/a; System.out.println(sum); } }
Java
["2 11 3\n0 1\n1 1", "0 5 2", "1 3 2\n1 2"]
2 seconds
["3", "2", "0"]
NoteIn the first sample Vasya can take $$$3$$$ breaks starting after $$$2$$$, $$$5$$$ and $$$8$$$ minutes after the beginning of the day.In the second sample Vasya can take $$$2$$$ breaks starting after $$$0$$$ and $$$2$$$ minutes after the beginning of the day.In the third sample Vasya can't take any breaks.
Java 8
standard input
[ "implementation" ]
00acb3b54975820989a788b9389c7c0b
The first line contains three integers $$$n$$$, $$$L$$$ and $$$a$$$ ($$$0 \le n \le 10^{5}$$$, $$$1 \le L \le 10^{9}$$$, $$$1 \le a \le L$$$). The $$$i$$$-th of the next $$$n$$$ lines contains two integers $$$t_{i}$$$ and $$$l_{i}$$$ ($$$0 \le t_{i} \le L - 1$$$, $$$1 \le l_{i} \le L$$$). It is guaranteed that $$$t_{i} + l_{i} \le t_{i + 1}$$$ and $$$t_{n} + l_{n} \le L$$$.
1,000
Output one integer  — the maximum number of breaks.
standard output
PASSED
b6b97ea9e981debab7b9fe91987c3bc3
train_002.jsonl
1538750100
Vasya has recently got a job as a cashier at a local store. His day at work is $$$L$$$ minutes long. Vasya has already memorized $$$n$$$ regular customers, the $$$i$$$-th of which comes after $$$t_{i}$$$ minutes after the beginning of the day, and his service consumes $$$l_{i}$$$ minutes. It is guaranteed that no customer will arrive while Vasya is servicing another customer. Vasya is a bit lazy, so he likes taking smoke breaks for $$$a$$$ minutes each. Those breaks may go one after another, but Vasya must be present at work during all the time periods he must serve regular customers, otherwise one of them may alert his boss. What is the maximum number of breaks Vasya can take during the day?
256 megabytes
import java.util.*; import java.lang.*; import java.math.*; import java.io.*; public class Main { public static void main(String[] args) throws IOException{ // TODO Auto-generated method stub Reader.init(System.in); int n=Reader.nextInt(); int l=Reader.nextInt(); int a=Reader.nextInt(); int[] arr1=new int[n+2]; int[] arr2=new int[n+2]; arr1[0]=0; arr2[0]=0; arr1[n+1]=l; int ans=0; for(int i=1;i<n+1;i++) { arr1[i]=Reader.nextInt(); arr2[i]=Reader.nextInt(); } for(int i=0;i<n+1;i++) { ans+=(arr1[i+1]-(arr2[i]+arr1[i]))/a; } System.out.println(ans); } } class node{ int brk1; int brk2; node(int brk1,int brk2){ this.brk1=brk1; this.brk2=brk2; } } class segment_tree { long[] tree; long[] arr; segment_tree(long n,long[] arr){ tree=new long[(int)(4*n)]; this.arr=arr; } public void build(int node,int l,int r) { if(l==r) { tree[node]=arr[l]; } else { int mid=(l+r)/2; build(2*node+1,l,mid); build(2*node+2,mid+1,r); tree[node]=tree[2*node+1]+tree[2*node+2]; } } public void update(int node, int index,int n,int l,int r) { if(l==r) { if(arr[index]==0) { arr[index]+=(long)Math.pow(2, n-1-index); tree[node]+=(long)Math.pow(2, n-1-index); } } else { int mid=(l+r)/2; if(index<=mid) { this.update(2*node+1, index, n, l, mid); } else { this.update(2*node+2, index, n, mid+1, r); } tree[node]=tree[2*node+1]+tree[2*node+2]; } } public long sum(int node,int l,int r,int ql,int qr) { if(ql>r || qr<l ) { return 0; } else if(r<=qr && l>=ql) { return tree[node]; } else { int mid=(l+r)/2; return (this.sum(2*node+1,l,mid, ql, qr)+this.sum(2*node+2, mid+1, r, ql, qr)); } } } /** Class for buffered reading int and double values */ class a implements Comparator<node>{ public int compare(node n1,node n2){ if(n1.brk1>n2.brk2) { return -1; } else if(n1.brk1<n2.brk1) { return 11; } else { return 0; } } } class Reader { static BufferedReader reader; static StringTokenizer tokenizer; /** call this method to initialize reader for InputStream */ static void init(InputStream input) { reader = new BufferedReader( new InputStreamReader(input) ); tokenizer = new StringTokenizer(""); } /** get next word */ static String next() throws IOException { while ( ! tokenizer.hasMoreTokens() ) { //TODO add check for eof if necessary tokenizer = new StringTokenizer( reader.readLine() ); } return tokenizer.nextToken(); } static int nextInt() throws IOException { return Integer.parseInt( next() ); } static long nextlong() throws IOException{ return Long.parseLong(next()); } static double nextDouble() throws IOException { return Double.parseDouble( next() ); } }
Java
["2 11 3\n0 1\n1 1", "0 5 2", "1 3 2\n1 2"]
2 seconds
["3", "2", "0"]
NoteIn the first sample Vasya can take $$$3$$$ breaks starting after $$$2$$$, $$$5$$$ and $$$8$$$ minutes after the beginning of the day.In the second sample Vasya can take $$$2$$$ breaks starting after $$$0$$$ and $$$2$$$ minutes after the beginning of the day.In the third sample Vasya can't take any breaks.
Java 8
standard input
[ "implementation" ]
00acb3b54975820989a788b9389c7c0b
The first line contains three integers $$$n$$$, $$$L$$$ and $$$a$$$ ($$$0 \le n \le 10^{5}$$$, $$$1 \le L \le 10^{9}$$$, $$$1 \le a \le L$$$). The $$$i$$$-th of the next $$$n$$$ lines contains two integers $$$t_{i}$$$ and $$$l_{i}$$$ ($$$0 \le t_{i} \le L - 1$$$, $$$1 \le l_{i} \le L$$$). It is guaranteed that $$$t_{i} + l_{i} \le t_{i + 1}$$$ and $$$t_{n} + l_{n} \le L$$$.
1,000
Output one integer  — the maximum number of breaks.
standard output
PASSED
162ba25ea8b4ac1ec048b3c93a4dc7e4
train_002.jsonl
1538750100
Vasya has recently got a job as a cashier at a local store. His day at work is $$$L$$$ minutes long. Vasya has already memorized $$$n$$$ regular customers, the $$$i$$$-th of which comes after $$$t_{i}$$$ minutes after the beginning of the day, and his service consumes $$$l_{i}$$$ minutes. It is guaranteed that no customer will arrive while Vasya is servicing another customer. Vasya is a bit lazy, so he likes taking smoke breaks for $$$a$$$ minutes each. Those breaks may go one after another, but Vasya must be present at work during all the time periods he must serve regular customers, otherwise one of them may alert his boss. What is the maximum number of breaks Vasya can take during the day?
256 megabytes
import java.io.BufferedOutputStream; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.StringTokenizer; public class Round541ProblemA { public static void main(String[] args) { // TODO Auto-generated method stub out=new PrintWriter(new BufferedOutputStream(System.out)); FastReader s=new FastReader(); int n=s.nextInt(); int L=s.nextInt(); int a=s.nextInt(); if(n==0) { out.println(L/a); out.close(); return; } int[][] arr=new int[n][2]; for(int i=0;i<n;i++) { int t=s.nextInt(); int l=s.nextInt(); arr[i][0]=t; arr[i][1]=l; } long breaks=0; breaks+=(arr[0][0]-0)/a; for(int i=0;i<n-1;i++) { breaks+=(long)(arr[i+1][0]-arr[i][0]-arr[i][1])/(long)a; } breaks+=(long)(L-arr[n-1][0]-arr[n-1][1])/(long)a; // breaks=sum/a; out.println(breaks); out.close(); } public static PrintWriter out; public static class FastReader { BufferedReader br; StringTokenizer st; //it reads the data about the specified point and divide the data about it ,it is quite fast //than using direct public FastReader() { br = new BufferedReader(new InputStreamReader(System.in)); } String next() { while (st == null || !st.hasMoreTokens()) { try { st = new StringTokenizer(br.readLine()); } catch (Exception e) { e.printStackTrace(); } } return st.nextToken(); } int nextInt() { return Integer.parseInt(next());//converts string to integer } double nextDouble() { return Double.parseDouble(next()); } long nextLong() { return Long.parseLong(next()); } String nextLine() { String str = ""; try { str = br.readLine(); } catch (Exception e) { e.printStackTrace(); } return str; } } }
Java
["2 11 3\n0 1\n1 1", "0 5 2", "1 3 2\n1 2"]
2 seconds
["3", "2", "0"]
NoteIn the first sample Vasya can take $$$3$$$ breaks starting after $$$2$$$, $$$5$$$ and $$$8$$$ minutes after the beginning of the day.In the second sample Vasya can take $$$2$$$ breaks starting after $$$0$$$ and $$$2$$$ minutes after the beginning of the day.In the third sample Vasya can't take any breaks.
Java 8
standard input
[ "implementation" ]
00acb3b54975820989a788b9389c7c0b
The first line contains three integers $$$n$$$, $$$L$$$ and $$$a$$$ ($$$0 \le n \le 10^{5}$$$, $$$1 \le L \le 10^{9}$$$, $$$1 \le a \le L$$$). The $$$i$$$-th of the next $$$n$$$ lines contains two integers $$$t_{i}$$$ and $$$l_{i}$$$ ($$$0 \le t_{i} \le L - 1$$$, $$$1 \le l_{i} \le L$$$). It is guaranteed that $$$t_{i} + l_{i} \le t_{i + 1}$$$ and $$$t_{n} + l_{n} \le L$$$.
1,000
Output one integer  — the maximum number of breaks.
standard output
PASSED
31e494c5586ad4810697ed97d87cd467
train_002.jsonl
1538750100
Vasya has recently got a job as a cashier at a local store. His day at work is $$$L$$$ minutes long. Vasya has already memorized $$$n$$$ regular customers, the $$$i$$$-th of which comes after $$$t_{i}$$$ minutes after the beginning of the day, and his service consumes $$$l_{i}$$$ minutes. It is guaranteed that no customer will arrive while Vasya is servicing another customer. Vasya is a bit lazy, so he likes taking smoke breaks for $$$a$$$ minutes each. Those breaks may go one after another, but Vasya must be present at work during all the time periods he must serve regular customers, otherwise one of them may alert his boss. What is the maximum number of breaks Vasya can take during the day?
256 megabytes
import java.util.*; public class A { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int L = sc.nextInt(); int a = sc.nextInt(); int[] start = new int[n]; int[] length = new int[n]; int numB = 0; for (int i = 0; i < n; i++) { start[i] = sc.nextInt(); length[i] = sc.nextInt(); } int currCus = 0; int time = 0; if (n == 0) { numB += L / a; } else { while (time <= L) { numB += (start[currCus] - time) / a; time = start[currCus] + length[currCus]; if (currCus == n - 1) { numB += (L - time) / a; break; } currCus++; } } System.out.println(numB); } }
Java
["2 11 3\n0 1\n1 1", "0 5 2", "1 3 2\n1 2"]
2 seconds
["3", "2", "0"]
NoteIn the first sample Vasya can take $$$3$$$ breaks starting after $$$2$$$, $$$5$$$ and $$$8$$$ minutes after the beginning of the day.In the second sample Vasya can take $$$2$$$ breaks starting after $$$0$$$ and $$$2$$$ minutes after the beginning of the day.In the third sample Vasya can't take any breaks.
Java 8
standard input
[ "implementation" ]
00acb3b54975820989a788b9389c7c0b
The first line contains three integers $$$n$$$, $$$L$$$ and $$$a$$$ ($$$0 \le n \le 10^{5}$$$, $$$1 \le L \le 10^{9}$$$, $$$1 \le a \le L$$$). The $$$i$$$-th of the next $$$n$$$ lines contains two integers $$$t_{i}$$$ and $$$l_{i}$$$ ($$$0 \le t_{i} \le L - 1$$$, $$$1 \le l_{i} \le L$$$). It is guaranteed that $$$t_{i} + l_{i} \le t_{i + 1}$$$ and $$$t_{n} + l_{n} \le L$$$.
1,000
Output one integer  — the maximum number of breaks.
standard output
PASSED
f4326ae5f2103a04d0f6431c8a447509
train_002.jsonl
1538750100
Vasya has recently got a job as a cashier at a local store. His day at work is $$$L$$$ minutes long. Vasya has already memorized $$$n$$$ regular customers, the $$$i$$$-th of which comes after $$$t_{i}$$$ minutes after the beginning of the day, and his service consumes $$$l_{i}$$$ minutes. It is guaranteed that no customer will arrive while Vasya is servicing another customer. Vasya is a bit lazy, so he likes taking smoke breaks for $$$a$$$ minutes each. Those breaks may go one after another, but Vasya must be present at work during all the time periods he must serve regular customers, otherwise one of them may alert his boss. What is the maximum number of breaks Vasya can take during the day?
256 megabytes
/* Roses are red Memes are neat All my test cases time out Lmao yeet */ import java.util.*; import java.io.*; public class A { public static void main(String args[]) throws Exception { BufferedReader infile = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(infile.readLine()); int N = Integer.parseInt(st.nextToken()); int L = Integer.parseInt(st.nextToken()); int A = Integer.parseInt(st.nextToken()); int[] arr1 = new int[N]; int[] arr2 = new int[N]; for(int i=0; i < N; i++) { st = new StringTokenizer(infile.readLine()); int x = Integer.parseInt(st.nextToken()); int y = Integer.parseInt(st.nextToken())+x; arr1[i] = x; arr2[i] = y; } int res = 0; for(int i=1; i < N; i++) res += (arr1[i]-arr2[i-1])/A; if(N > 0) res += (L-arr2[N-1])/A+arr1[0]/A; else res += L/A; System.out.println(res); } }
Java
["2 11 3\n0 1\n1 1", "0 5 2", "1 3 2\n1 2"]
2 seconds
["3", "2", "0"]
NoteIn the first sample Vasya can take $$$3$$$ breaks starting after $$$2$$$, $$$5$$$ and $$$8$$$ minutes after the beginning of the day.In the second sample Vasya can take $$$2$$$ breaks starting after $$$0$$$ and $$$2$$$ minutes after the beginning of the day.In the third sample Vasya can't take any breaks.
Java 8
standard input
[ "implementation" ]
00acb3b54975820989a788b9389c7c0b
The first line contains three integers $$$n$$$, $$$L$$$ and $$$a$$$ ($$$0 \le n \le 10^{5}$$$, $$$1 \le L \le 10^{9}$$$, $$$1 \le a \le L$$$). The $$$i$$$-th of the next $$$n$$$ lines contains two integers $$$t_{i}$$$ and $$$l_{i}$$$ ($$$0 \le t_{i} \le L - 1$$$, $$$1 \le l_{i} \le L$$$). It is guaranteed that $$$t_{i} + l_{i} \le t_{i + 1}$$$ and $$$t_{n} + l_{n} \le L$$$.
1,000
Output one integer  — the maximum number of breaks.
standard output
PASSED
8a5487f4f219f0c680170e8924a35ba4
train_002.jsonl
1538750100
Vasya has recently got a job as a cashier at a local store. His day at work is $$$L$$$ minutes long. Vasya has already memorized $$$n$$$ regular customers, the $$$i$$$-th of which comes after $$$t_{i}$$$ minutes after the beginning of the day, and his service consumes $$$l_{i}$$$ minutes. It is guaranteed that no customer will arrive while Vasya is servicing another customer. Vasya is a bit lazy, so he likes taking smoke breaks for $$$a$$$ minutes each. Those breaks may go one after another, but Vasya must be present at work during all the time periods he must serve regular customers, otherwise one of them may alert his boss. What is the maximum number of breaks Vasya can take during the day?
256 megabytes
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner in=new Scanner(System.in); long n=in.nextInt(); long L=in.nextInt(); long a=in.nextInt(); long t,l; if(n==0) { System.out.print(L/a); } else { t=in.nextLong(); l=in.nextLong(); long sum=0; sum+=((t)/a); long shag; shag=t+l; for(int i=1; i<n; i++) { l=in.nextLong(); t=in.nextLong(); sum+=((l-shag)/a); shag=t+l; } sum+=((L-shag)/a); System.out.print(sum); } } }
Java
["2 11 3\n0 1\n1 1", "0 5 2", "1 3 2\n1 2"]
2 seconds
["3", "2", "0"]
NoteIn the first sample Vasya can take $$$3$$$ breaks starting after $$$2$$$, $$$5$$$ and $$$8$$$ minutes after the beginning of the day.In the second sample Vasya can take $$$2$$$ breaks starting after $$$0$$$ and $$$2$$$ minutes after the beginning of the day.In the third sample Vasya can't take any breaks.
Java 8
standard input
[ "implementation" ]
00acb3b54975820989a788b9389c7c0b
The first line contains three integers $$$n$$$, $$$L$$$ and $$$a$$$ ($$$0 \le n \le 10^{5}$$$, $$$1 \le L \le 10^{9}$$$, $$$1 \le a \le L$$$). The $$$i$$$-th of the next $$$n$$$ lines contains two integers $$$t_{i}$$$ and $$$l_{i}$$$ ($$$0 \le t_{i} \le L - 1$$$, $$$1 \le l_{i} \le L$$$). It is guaranteed that $$$t_{i} + l_{i} \le t_{i + 1}$$$ and $$$t_{n} + l_{n} \le L$$$.
1,000
Output one integer  — the maximum number of breaks.
standard output
PASSED
fe5da73f28fe76a341fe533fe11904f0
train_002.jsonl
1538750100
Vasya has recently got a job as a cashier at a local store. His day at work is $$$L$$$ minutes long. Vasya has already memorized $$$n$$$ regular customers, the $$$i$$$-th of which comes after $$$t_{i}$$$ minutes after the beginning of the day, and his service consumes $$$l_{i}$$$ minutes. It is guaranteed that no customer will arrive while Vasya is servicing another customer. Vasya is a bit lazy, so he likes taking smoke breaks for $$$a$$$ minutes each. Those breaks may go one after another, but Vasya must be present at work during all the time periods he must serve regular customers, otherwise one of them may alert his boss. What is the maximum number of breaks Vasya can take during the day?
256 megabytes
import java.util.Scanner; public class Main { public static void main(String[] args) { // Excercise_1059A q = new Excercise_1059A(); // q.qwerty(); Scanner in = new Scanner(System.in); String firstLine = in.nextLine(); String[] fl = firstLine.split(" "); int count = Integer.valueOf(fl[0]); int n = Integer.valueOf(fl[1]); int a = Integer.valueOf(fl[2]); if (count == 0){ System.out.println((int) n / a); } else { int[] start = new int[count]; int[] finish = new int[count]; for (int i = 0; i < count; i++) { String client = in.nextLine(); String[] cl = client.split(" "); start[i] = Integer.valueOf(cl[0]); finish[i] = Integer.valueOf(cl[1]) - 1 + start[i]; } // for (int i = 0; i < start.length; i++){ // System.out.print(start[i] + " "); // } // System.out.println(); // for (int i = 0; i < finish.length; i++){ // System.out.print(finish[i] + " "); // } // System.out.println(); int answer = 0; answer = (int) start[0] / a; // System.out.println(answer + " #"); for (int i = 0; i < finish.length - 1; i++) { answer = answer + (int) ((start[i + 1] - (finish[i] + 1)) / a); // System.out.println(answer + " " + i); } // System.out.println((n - 1) - (finish[finish.length - 1])); answer = answer + (int) (((n - 1) - (finish[finish.length - 1])) / a); System.out.println(answer); } } }
Java
["2 11 3\n0 1\n1 1", "0 5 2", "1 3 2\n1 2"]
2 seconds
["3", "2", "0"]
NoteIn the first sample Vasya can take $$$3$$$ breaks starting after $$$2$$$, $$$5$$$ and $$$8$$$ minutes after the beginning of the day.In the second sample Vasya can take $$$2$$$ breaks starting after $$$0$$$ and $$$2$$$ minutes after the beginning of the day.In the third sample Vasya can't take any breaks.
Java 8
standard input
[ "implementation" ]
00acb3b54975820989a788b9389c7c0b
The first line contains three integers $$$n$$$, $$$L$$$ and $$$a$$$ ($$$0 \le n \le 10^{5}$$$, $$$1 \le L \le 10^{9}$$$, $$$1 \le a \le L$$$). The $$$i$$$-th of the next $$$n$$$ lines contains two integers $$$t_{i}$$$ and $$$l_{i}$$$ ($$$0 \le t_{i} \le L - 1$$$, $$$1 \le l_{i} \le L$$$). It is guaranteed that $$$t_{i} + l_{i} \le t_{i + 1}$$$ and $$$t_{n} + l_{n} \le L$$$.
1,000
Output one integer  — the maximum number of breaks.
standard output
PASSED
5ccac95e99c6f6d8f0a7eadea5baf83e
train_002.jsonl
1538750100
Vasya has recently got a job as a cashier at a local store. His day at work is $$$L$$$ minutes long. Vasya has already memorized $$$n$$$ regular customers, the $$$i$$$-th of which comes after $$$t_{i}$$$ minutes after the beginning of the day, and his service consumes $$$l_{i}$$$ minutes. It is guaranteed that no customer will arrive while Vasya is servicing another customer. Vasya is a bit lazy, so he likes taking smoke breaks for $$$a$$$ minutes each. Those breaks may go one after another, but Vasya must be present at work during all the time periods he must serve regular customers, otherwise one of them may alert his boss. What is the maximum number of breaks Vasya can take during the day?
256 megabytes
import java.util.Scanner; public class codeforces { public static void main(String args[]) { Scanner in = new Scanner(System.in); int n = in.nextInt(); int L = in.nextInt(); int a = in.nextInt(); int x = 0; if(n==0) { System.out.println(L/a); } else { int tab [][] = new int[n][2]; int i =0 , j=0; for ( i=0 ;i<n;i++) { for ( j = 0 ; j<2 ; j++) { tab[i][j] = in.nextInt(); } } if(tab[0][0]>=a) x=x+tab[0][0]/a; for ( i=0 ;i<n-1;i++) { if (tab[i+1][0]-(tab[i][0]+tab[i][1]) >=a) x = x + (tab[i+1][0]-(tab[i][0]+tab[i][1]))/a; } if(L-(tab[n-1][0]+tab[n-1][1])>=a) x=x+ ((L-(tab[n-1][0]+tab[n-1][1]))/a); System.out.println(x); } } }
Java
["2 11 3\n0 1\n1 1", "0 5 2", "1 3 2\n1 2"]
2 seconds
["3", "2", "0"]
NoteIn the first sample Vasya can take $$$3$$$ breaks starting after $$$2$$$, $$$5$$$ and $$$8$$$ minutes after the beginning of the day.In the second sample Vasya can take $$$2$$$ breaks starting after $$$0$$$ and $$$2$$$ minutes after the beginning of the day.In the third sample Vasya can't take any breaks.
Java 8
standard input
[ "implementation" ]
00acb3b54975820989a788b9389c7c0b
The first line contains three integers $$$n$$$, $$$L$$$ and $$$a$$$ ($$$0 \le n \le 10^{5}$$$, $$$1 \le L \le 10^{9}$$$, $$$1 \le a \le L$$$). The $$$i$$$-th of the next $$$n$$$ lines contains two integers $$$t_{i}$$$ and $$$l_{i}$$$ ($$$0 \le t_{i} \le L - 1$$$, $$$1 \le l_{i} \le L$$$). It is guaranteed that $$$t_{i} + l_{i} \le t_{i + 1}$$$ and $$$t_{n} + l_{n} \le L$$$.
1,000
Output one integer  — the maximum number of breaks.
standard output
PASSED
c580aeb7c89412111f9b9afcc951d1d4
train_002.jsonl
1538750100
Vasya has recently got a job as a cashier at a local store. His day at work is $$$L$$$ minutes long. Vasya has already memorized $$$n$$$ regular customers, the $$$i$$$-th of which comes after $$$t_{i}$$$ minutes after the beginning of the day, and his service consumes $$$l_{i}$$$ minutes. It is guaranteed that no customer will arrive while Vasya is servicing another customer. Vasya is a bit lazy, so he likes taking smoke breaks for $$$a$$$ minutes each. Those breaks may go one after another, but Vasya must be present at work during all the time periods he must serve regular customers, otherwise one of them may alert his boss. What is the maximum number of breaks Vasya can take during the day?
256 megabytes
import java.util.Scanner; public class Cashier { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int customers = scan.nextInt(); int minutes = scan.nextInt(); int b = scan.nextInt(); int count = 0; int start = 0; int end = 0; if(customers == 0) { System.out.println(minutes / b); return; } start = scan.nextInt(); count += start/b; end = start + scan.nextInt(); for(int i = 0; i < customers-1; i++) { start = scan.nextInt(); if(start - end >= b) count+= (start-end)/b; end = scan.nextInt() + start; } if(minutes - end >= 0) count += (minutes - end) / b; System.out.println(count); } }
Java
["2 11 3\n0 1\n1 1", "0 5 2", "1 3 2\n1 2"]
2 seconds
["3", "2", "0"]
NoteIn the first sample Vasya can take $$$3$$$ breaks starting after $$$2$$$, $$$5$$$ and $$$8$$$ minutes after the beginning of the day.In the second sample Vasya can take $$$2$$$ breaks starting after $$$0$$$ and $$$2$$$ minutes after the beginning of the day.In the third sample Vasya can't take any breaks.
Java 8
standard input
[ "implementation" ]
00acb3b54975820989a788b9389c7c0b
The first line contains three integers $$$n$$$, $$$L$$$ and $$$a$$$ ($$$0 \le n \le 10^{5}$$$, $$$1 \le L \le 10^{9}$$$, $$$1 \le a \le L$$$). The $$$i$$$-th of the next $$$n$$$ lines contains two integers $$$t_{i}$$$ and $$$l_{i}$$$ ($$$0 \le t_{i} \le L - 1$$$, $$$1 \le l_{i} \le L$$$). It is guaranteed that $$$t_{i} + l_{i} \le t_{i + 1}$$$ and $$$t_{n} + l_{n} \le L$$$.
1,000
Output one integer  — the maximum number of breaks.
standard output
PASSED
8ed9809319a1336a52451dcbb3da87e6
train_002.jsonl
1489233600
Innokentiy decides to change the password in the social net "Contact!", but he is too lazy to invent a new password by himself. That is why he needs your help. Innokentiy decides that new password should satisfy the following conditions: the length of the password must be equal to n, the password should consist only of lowercase Latin letters, the number of distinct symbols in the password must be equal to k, any two consecutive symbols in the password must be distinct. Your task is to help Innokentiy and to invent a new password which will satisfy all given conditions.
256 megabytes
import java.util.Scanner; public class NewPassword { public static void main(String[] args) { Scanner in=new Scanner(System.in); int n=in.nextInt(); int k=in.nextInt(); String s=""; for(int i=0;i<n;i++){ s+=(char)((int)'a'+(i%k)); } System.out.println(s); } }
Java
["4 3", "6 6", "5 2"]
1 second
["java", "python", "phphp"]
NoteIn the first test there is one of the appropriate new passwords — java, because its length is equal to 4 and 3 distinct lowercase letters a, j and v are used in it.In the second test there is one of the appropriate new passwords — python, because its length is equal to 6 and it consists of 6 distinct lowercase letters.In the third test there is one of the appropriate new passwords — phphp, because its length is equal to 5 and 2 distinct lowercase letters p and h are used in it.Pay attention the condition that no two identical symbols are consecutive is correct for all appropriate passwords in tests.
Java 11
standard input
[ "implementation", "*special" ]
39f5e934bf293053246bd3faa8061c3b
The first line contains two positive integers n and k (2 ≤ n ≤ 100, 2 ≤ k ≤ min(n, 26)) — the length of the password and the number of distinct symbols in it. Pay attention that a desired new password always exists.
800
Print any password which satisfies all conditions given by Innokentiy.
standard output
PASSED
e7df773c228357d585e48169b2a76e07
train_002.jsonl
1489233600
Innokentiy decides to change the password in the social net "Contact!", but he is too lazy to invent a new password by himself. That is why he needs your help. Innokentiy decides that new password should satisfy the following conditions: the length of the password must be equal to n, the password should consist only of lowercase Latin letters, the number of distinct symbols in the password must be equal to k, any two consecutive symbols in the password must be distinct. Your task is to help Innokentiy and to invent a new password which will satisfy all given conditions.
256 megabytes
import java.util.*; public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); int k = in.nextInt(); String s = ""; for (int i = 0; i < n; i++) { s += (char)((int)'a' + i % k); } System.out.println(s); } }
Java
["4 3", "6 6", "5 2"]
1 second
["java", "python", "phphp"]
NoteIn the first test there is one of the appropriate new passwords — java, because its length is equal to 4 and 3 distinct lowercase letters a, j and v are used in it.In the second test there is one of the appropriate new passwords — python, because its length is equal to 6 and it consists of 6 distinct lowercase letters.In the third test there is one of the appropriate new passwords — phphp, because its length is equal to 5 and 2 distinct lowercase letters p and h are used in it.Pay attention the condition that no two identical symbols are consecutive is correct for all appropriate passwords in tests.
Java 11
standard input
[ "implementation", "*special" ]
39f5e934bf293053246bd3faa8061c3b
The first line contains two positive integers n and k (2 ≤ n ≤ 100, 2 ≤ k ≤ min(n, 26)) — the length of the password and the number of distinct symbols in it. Pay attention that a desired new password always exists.
800
Print any password which satisfies all conditions given by Innokentiy.
standard output
PASSED
8eea8d867b17be71efd17853ed9af92e
train_002.jsonl
1489233600
Innokentiy decides to change the password in the social net "Contact!", but he is too lazy to invent a new password by himself. That is why he needs your help. Innokentiy decides that new password should satisfy the following conditions: the length of the password must be equal to n, the password should consist only of lowercase Latin letters, the number of distinct symbols in the password must be equal to k, any two consecutive symbols in the password must be distinct. Your task is to help Innokentiy and to invent a new password which will satisfy all given conditions.
256 megabytes
import java.util.* ; import java.io.* ; public class Main { public static Scanner in= new Scanner(System.in) ; public static void main(String[] args) { int n = in.nextInt(), k = in.nextInt(); StringBuilder x = new StringBuilder() ; String dict = "qwertyuiopasdfghjklzxcvbnm" ; for( int i = 0 ; i < n ; ++i ) { x.append( dict.charAt(i%k) ) ; } System.out.println(x.toString()) ; } }
Java
["4 3", "6 6", "5 2"]
1 second
["java", "python", "phphp"]
NoteIn the first test there is one of the appropriate new passwords — java, because its length is equal to 4 and 3 distinct lowercase letters a, j and v are used in it.In the second test there is one of the appropriate new passwords — python, because its length is equal to 6 and it consists of 6 distinct lowercase letters.In the third test there is one of the appropriate new passwords — phphp, because its length is equal to 5 and 2 distinct lowercase letters p and h are used in it.Pay attention the condition that no two identical symbols are consecutive is correct for all appropriate passwords in tests.
Java 11
standard input
[ "implementation", "*special" ]
39f5e934bf293053246bd3faa8061c3b
The first line contains two positive integers n and k (2 ≤ n ≤ 100, 2 ≤ k ≤ min(n, 26)) — the length of the password and the number of distinct symbols in it. Pay attention that a desired new password always exists.
800
Print any password which satisfies all conditions given by Innokentiy.
standard output
PASSED
b138e7640572727e634aef2f733abcb8
train_002.jsonl
1489233600
Innokentiy decides to change the password in the social net "Contact!", but he is too lazy to invent a new password by himself. That is why he needs your help. Innokentiy decides that new password should satisfy the following conditions: the length of the password must be equal to n, the password should consist only of lowercase Latin letters, the number of distinct symbols in the password must be equal to k, any two consecutive symbols in the password must be distinct. Your task is to help Innokentiy and to invent a new password which will satisfy all given conditions.
256 megabytes
import java.util.Scanner; public class Main { private static final Scanner scanner = new Scanner(System.in); public static void main(String[] args) { int n = scanner.nextInt(); int k = scanner.nextInt(); String s = ""; int a = 97; int j = 0; for (int i = 0; i < k; i++) { s = s + (char) a; a++; } while (s.length() < n) { s = s + s.charAt(j); j++; if (j == k) j = 0; } System.out.println(s); } }
Java
["4 3", "6 6", "5 2"]
1 second
["java", "python", "phphp"]
NoteIn the first test there is one of the appropriate new passwords — java, because its length is equal to 4 and 3 distinct lowercase letters a, j and v are used in it.In the second test there is one of the appropriate new passwords — python, because its length is equal to 6 and it consists of 6 distinct lowercase letters.In the third test there is one of the appropriate new passwords — phphp, because its length is equal to 5 and 2 distinct lowercase letters p and h are used in it.Pay attention the condition that no two identical symbols are consecutive is correct for all appropriate passwords in tests.
Java 11
standard input
[ "implementation", "*special" ]
39f5e934bf293053246bd3faa8061c3b
The first line contains two positive integers n and k (2 ≤ n ≤ 100, 2 ≤ k ≤ min(n, 26)) — the length of the password and the number of distinct symbols in it. Pay attention that a desired new password always exists.
800
Print any password which satisfies all conditions given by Innokentiy.
standard output
PASSED
49b00c7cefced22855f5cbb511c2d763
train_002.jsonl
1489233600
Innokentiy decides to change the password in the social net "Contact!", but he is too lazy to invent a new password by himself. That is why he needs your help. Innokentiy decides that new password should satisfy the following conditions: the length of the password must be equal to n, the password should consist only of lowercase Latin letters, the number of distinct symbols in the password must be equal to k, any two consecutive symbols in the password must be distinct. Your task is to help Innokentiy and to invent a new password which will satisfy all given conditions.
256 megabytes
//package com.mass.codeforces; import java.io.File; import java.io.FileNotFoundException; import java.math.BigInteger; import java.util.Arrays; import java.util.Scanner; public class solution { public static void main(String[] args) throws FileNotFoundException { // File file // = new File("C:\\Users\\mass\\Documents\\NetBeansProjects\\codeforces\\src\\main\\java\\com\\mass\\codeforces\\test.txt"); // Scanner sc = new Scanner(file); Scanner sc = new Scanner(System.in); // for (int j = 0; j < 3; j++) { String first = sc.nextLine(); String[] split = first.split(" "); int n=Integer.parseInt(split[0]); int k=Integer.parseInt(split[1]); String password=""; char[] alphabet = "abcdefghijklmnopqrstuvwxyz".toCharArray(); for (int i = 0; i < n; i++) { password+=alphabet[i%k]; } System.out.println(password); // } } }
Java
["4 3", "6 6", "5 2"]
1 second
["java", "python", "phphp"]
NoteIn the first test there is one of the appropriate new passwords — java, because its length is equal to 4 and 3 distinct lowercase letters a, j and v are used in it.In the second test there is one of the appropriate new passwords — python, because its length is equal to 6 and it consists of 6 distinct lowercase letters.In the third test there is one of the appropriate new passwords — phphp, because its length is equal to 5 and 2 distinct lowercase letters p and h are used in it.Pay attention the condition that no two identical symbols are consecutive is correct for all appropriate passwords in tests.
Java 11
standard input
[ "implementation", "*special" ]
39f5e934bf293053246bd3faa8061c3b
The first line contains two positive integers n and k (2 ≤ n ≤ 100, 2 ≤ k ≤ min(n, 26)) — the length of the password and the number of distinct symbols in it. Pay attention that a desired new password always exists.
800
Print any password which satisfies all conditions given by Innokentiy.
standard output
PASSED
479543f019058499487a6b9e9f0c8b3b
train_002.jsonl
1489233600
Innokentiy decides to change the password in the social net "Contact!", but he is too lazy to invent a new password by himself. That is why he needs your help. Innokentiy decides that new password should satisfy the following conditions: the length of the password must be equal to n, the password should consist only of lowercase Latin letters, the number of distinct symbols in the password must be equal to k, any two consecutive symbols in the password must be distinct. Your task is to help Innokentiy and to invent a new password which will satisfy all given conditions.
256 megabytes
import java.util.Scanner; public class Problems { public static void main(String[] args) { Scanner s = new Scanner(System.in); String alph = "abcdefghijklmnopqrstuvwxyz"; int n= s.nextInt(); int k= s.nextInt(); String alphabet = alph.substring(0,k); String password= alphabet; if(k == n) { System.out.println(password); }else{ for(int i=2;i<=n+1;i++) { if(n>k*i) { password = password+alphabet; }else{ int y=0; while(n>password.length()) { password = password+ alphabet.charAt(y); y++; } } } System.out.println(password); } } }
Java
["4 3", "6 6", "5 2"]
1 second
["java", "python", "phphp"]
NoteIn the first test there is one of the appropriate new passwords — java, because its length is equal to 4 and 3 distinct lowercase letters a, j and v are used in it.In the second test there is one of the appropriate new passwords — python, because its length is equal to 6 and it consists of 6 distinct lowercase letters.In the third test there is one of the appropriate new passwords — phphp, because its length is equal to 5 and 2 distinct lowercase letters p and h are used in it.Pay attention the condition that no two identical symbols are consecutive is correct for all appropriate passwords in tests.
Java 11
standard input
[ "implementation", "*special" ]
39f5e934bf293053246bd3faa8061c3b
The first line contains two positive integers n and k (2 ≤ n ≤ 100, 2 ≤ k ≤ min(n, 26)) — the length of the password and the number of distinct symbols in it. Pay attention that a desired new password always exists.
800
Print any password which satisfies all conditions given by Innokentiy.
standard output
PASSED
7de5f47a01f74793671886d20fb717a6
train_002.jsonl
1489233600
Innokentiy decides to change the password in the social net "Contact!", but he is too lazy to invent a new password by himself. That is why he needs your help. Innokentiy decides that new password should satisfy the following conditions: the length of the password must be equal to n, the password should consist only of lowercase Latin letters, the number of distinct symbols in the password must be equal to k, any two consecutive symbols in the password must be distinct. Your task is to help Innokentiy and to invent a new password which will satisfy all given conditions.
256 megabytes
// Long Contest 1, Problem G import java.io.*; import java.nio.charset.Charset; import java.util.Arrays; public class Main { public static void main(String[] args) { Charset charset = Charset.forName("ascii"); FastIO rd = new FastIO(System.in, System.out, charset); int n = rd.readInt(); int k = rd.readInt(); char[] letters = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'}; String word = ""; for(int i=0; i < n; i++) { word += letters[i%k]; } System.out.println(word); } } class FastIO { public final StringBuilder cache = new StringBuilder(1 << 20); private final InputStream is; private final OutputStream os; private final Charset charset; private StringBuilder defaultStringBuf = new StringBuilder(1 << 8); private byte[] buf = new byte[1 << 13]; private int bufLen; private int bufOffset; private int next; public FastIO(InputStream is, OutputStream os, Charset charset) { this.is = is; this.os = os; this.charset = charset; } public FastIO(InputStream is, OutputStream os) { this(is, os, Charset.forName("ascii")); } private int read() { while (bufLen == bufOffset) { bufOffset = 0; try { bufLen = is.read(buf); } catch (IOException e) { throw new RuntimeException(e); } if (bufLen == -1) { return -1; } } return buf[bufOffset++]; } public void skipBlank() { while (next >= 0 && next <= 32) { next = read(); } } public int readInt() { int sign = 1; skipBlank(); if (next == '+' || next == '-') { sign = next == '+' ? 1 : -1; next = read(); } int val = 0; if (sign == 1) { while (next >= '0' && next <= '9') { val = val * 10 + next - '0'; next = read(); } } else { while (next >= '0' && next <= '9') { val = val * 10 - next + '0'; next = read(); } } return val; } public long readLong() { int sign = 1; skipBlank(); if (next == '+' || next == '-') { sign = next == '+' ? 1 : -1; next = read(); } long val = 0; if (sign == 1) { while (next >= '0' && next <= '9') { val = val * 10 + next - '0'; next = read(); } } else { while (next >= '0' && next <= '9') { val = val * 10 - next + '0'; next = read(); } } return val; } public double readDouble() { boolean sign = true; skipBlank(); if (next == '+' || next == '-') { sign = next == '+'; next = read(); } long val = 0; while (next >= '0' && next <= '9') { val = val * 10 + next - '0'; next = read(); } if (next != '.') { return sign ? val : -val; } next = read(); long radix = 1; long point = 0; while (next >= '0' && next <= '9') { point = point * 10 + next - '0'; radix = radix * 10; next = read(); } double result = val + (double) point / radix; return sign ? result : -result; } public String readString(StringBuilder builder) { skipBlank(); while (next > 32) { builder.append((char) next); next = read(); } return builder.toString(); } public String readString() { defaultStringBuf.setLength(0); return readString(defaultStringBuf); } public int readLine(char[] data, int offset) { int originalOffset = offset; while (next != -1 && next != '\n') { data[offset++] = (char) next; next = read(); } return offset - originalOffset; } public int readString(char[] data, int offset) { skipBlank(); int originalOffset = offset; while (next > 32) { data[offset++] = (char) next; next = read(); } return offset - originalOffset; } public int readString(byte[] data, int offset) { skipBlank(); int originalOffset = offset; while (next > 32) { data[offset++] = (byte) next; next = read(); } return offset - originalOffset; } public char readChar() { skipBlank(); char c = (char) next; next = read(); return c; } public void flush() { try { os.write(cache.toString().getBytes(charset)); os.flush(); cache.setLength(0); } catch (IOException e) { throw new RuntimeException(e); } } public boolean hasMore() { skipBlank(); return next != -1; } }
Java
["4 3", "6 6", "5 2"]
1 second
["java", "python", "phphp"]
NoteIn the first test there is one of the appropriate new passwords — java, because its length is equal to 4 and 3 distinct lowercase letters a, j and v are used in it.In the second test there is one of the appropriate new passwords — python, because its length is equal to 6 and it consists of 6 distinct lowercase letters.In the third test there is one of the appropriate new passwords — phphp, because its length is equal to 5 and 2 distinct lowercase letters p and h are used in it.Pay attention the condition that no two identical symbols are consecutive is correct for all appropriate passwords in tests.
Java 11
standard input
[ "implementation", "*special" ]
39f5e934bf293053246bd3faa8061c3b
The first line contains two positive integers n and k (2 ≤ n ≤ 100, 2 ≤ k ≤ min(n, 26)) — the length of the password and the number of distinct symbols in it. Pay attention that a desired new password always exists.
800
Print any password which satisfies all conditions given by Innokentiy.
standard output
PASSED
ea7e4d66bff47c536bd6595a31889045
train_002.jsonl
1489233600
Innokentiy decides to change the password in the social net "Contact!", but he is too lazy to invent a new password by himself. That is why he needs your help. Innokentiy decides that new password should satisfy the following conditions: the length of the password must be equal to n, the password should consist only of lowercase Latin letters, the number of distinct symbols in the password must be equal to k, any two consecutive symbols in the password must be distinct. Your task is to help Innokentiy and to invent a new password which will satisfy all given conditions.
256 megabytes
import java.util.Random; import java.util.Scanner; import java.lang.*; public class Main { public static void main(String[] args) { Scanner input = new Scanner(System.in); Random random = new Random(); StringBuilder sb = new StringBuilder(); String alphabet = "abcdefghijklmnopqrstuvwxyz"; int passwordLength = input.nextInt(); int distinctCharNum = input.nextInt(); String distinct; for (int i = 0; i < distinctCharNum; i++) { sb.append(alphabet.charAt(i)); } distinct = sb.toString(); if (passwordLength == distinctCharNum) { System.out.println(distinct); }else{ int temp = 0; for (int i = 0; i < passwordLength - distinct.length(); i++) { sb.append(distinct.charAt(temp)); temp++; if (temp == distinct.length()) { temp = 0; } } System.out.println(sb.toString()); } } }
Java
["4 3", "6 6", "5 2"]
1 second
["java", "python", "phphp"]
NoteIn the first test there is one of the appropriate new passwords — java, because its length is equal to 4 and 3 distinct lowercase letters a, j and v are used in it.In the second test there is one of the appropriate new passwords — python, because its length is equal to 6 and it consists of 6 distinct lowercase letters.In the third test there is one of the appropriate new passwords — phphp, because its length is equal to 5 and 2 distinct lowercase letters p and h are used in it.Pay attention the condition that no two identical symbols are consecutive is correct for all appropriate passwords in tests.
Java 11
standard input
[ "implementation", "*special" ]
39f5e934bf293053246bd3faa8061c3b
The first line contains two positive integers n and k (2 ≤ n ≤ 100, 2 ≤ k ≤ min(n, 26)) — the length of the password and the number of distinct symbols in it. Pay attention that a desired new password always exists.
800
Print any password which satisfies all conditions given by Innokentiy.
standard output
PASSED
f5e76d4b4aa9077884172b9010309247
train_002.jsonl
1489233600
Innokentiy decides to change the password in the social net "Contact!", but he is too lazy to invent a new password by himself. That is why he needs your help. Innokentiy decides that new password should satisfy the following conditions: the length of the password must be equal to n, the password should consist only of lowercase Latin letters, the number of distinct symbols in the password must be equal to k, any two consecutive symbols in the password must be distinct. Your task is to help Innokentiy and to invent a new password which will satisfy all given conditions.
256 megabytes
import javax.swing.*; import java.util.Scanner; public class solution { public static void main(String[] args) { Scanner input = new Scanner(System.in); int totalLetters = input.nextInt(); int numberOfLetters = input.nextInt(); char[] letters = new char[numberOfLetters]; int theLetter = 97; for (int i = 0; i < numberOfLetters; i++) { letters[i] = (char) theLetter; theLetter ++; } int i = 0; String result = ""; while (i < totalLetters){ for (int j = 0; j < numberOfLetters; j++) { if (i == totalLetters) break; result += letters[j]; i ++; } } System.out.println(result); input.close(); } }
Java
["4 3", "6 6", "5 2"]
1 second
["java", "python", "phphp"]
NoteIn the first test there is one of the appropriate new passwords — java, because its length is equal to 4 and 3 distinct lowercase letters a, j and v are used in it.In the second test there is one of the appropriate new passwords — python, because its length is equal to 6 and it consists of 6 distinct lowercase letters.In the third test there is one of the appropriate new passwords — phphp, because its length is equal to 5 and 2 distinct lowercase letters p and h are used in it.Pay attention the condition that no two identical symbols are consecutive is correct for all appropriate passwords in tests.
Java 11
standard input
[ "implementation", "*special" ]
39f5e934bf293053246bd3faa8061c3b
The first line contains two positive integers n and k (2 ≤ n ≤ 100, 2 ≤ k ≤ min(n, 26)) — the length of the password and the number of distinct symbols in it. Pay attention that a desired new password always exists.
800
Print any password which satisfies all conditions given by Innokentiy.
standard output
PASSED
517e15a0d0c1c8f114f76c5f4e78b5c9
train_002.jsonl
1489233600
Innokentiy decides to change the password in the social net "Contact!", but he is too lazy to invent a new password by himself. That is why he needs your help. Innokentiy decides that new password should satisfy the following conditions: the length of the password must be equal to n, the password should consist only of lowercase Latin letters, the number of distinct symbols in the password must be equal to k, any two consecutive symbols in the password must be distinct. Your task is to help Innokentiy and to invent a new password which will satisfy all given conditions.
256 megabytes
import java.util.*; public class Main { public static void main(String[] args) { // write your code here Scanner in = new Scanner(System.in); int n = in.nextInt(); int k = in.nextInt(); String s =""; for (int i = 0; i < n; i++) { s+= (char)((int) 'a' + i%k); } System.out.println(s); } }
Java
["4 3", "6 6", "5 2"]
1 second
["java", "python", "phphp"]
NoteIn the first test there is one of the appropriate new passwords — java, because its length is equal to 4 and 3 distinct lowercase letters a, j and v are used in it.In the second test there is one of the appropriate new passwords — python, because its length is equal to 6 and it consists of 6 distinct lowercase letters.In the third test there is one of the appropriate new passwords — phphp, because its length is equal to 5 and 2 distinct lowercase letters p and h are used in it.Pay attention the condition that no two identical symbols are consecutive is correct for all appropriate passwords in tests.
Java 11
standard input
[ "implementation", "*special" ]
39f5e934bf293053246bd3faa8061c3b
The first line contains two positive integers n and k (2 ≤ n ≤ 100, 2 ≤ k ≤ min(n, 26)) — the length of the password and the number of distinct symbols in it. Pay attention that a desired new password always exists.
800
Print any password which satisfies all conditions given by Innokentiy.
standard output
PASSED
68cd5683fd8e12e36d1dc222d5539d7c
train_002.jsonl
1489233600
Innokentiy decides to change the password in the social net "Contact!", but he is too lazy to invent a new password by himself. That is why he needs your help. Innokentiy decides that new password should satisfy the following conditions: the length of the password must be equal to n, the password should consist only of lowercase Latin letters, the number of distinct symbols in the password must be equal to k, any two consecutive symbols in the password must be distinct. Your task is to help Innokentiy and to invent a new password which will satisfy all given conditions.
256 megabytes
// package cfa; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; import java.io.PrintWriter; import java.util.StringTokenizer; public class NewPassword { public static void main(String[] args) { InputStream inputStream = System.in; OutputStream outputStream = System.out; InputReader in = new InputReader(inputStream); PrintWriter out = new PrintWriter(outputStream); Solution sol = new Solution(); sol.solve(in, out); out.close(); } private static class Solution { private void solve(InputReader in, PrintWriter out) { int n=in.ni(), k=in.ni(); for (int j=0, i=0; j<n; ++j) { out.print((char)('a'+i)); i=(i+1)%k; } } } private static class InputReader { private BufferedReader reader; private StringTokenizer tokenizer; private InputReader(InputStream stream) { reader = new BufferedReader(new InputStreamReader(stream), 32768); tokenizer = null; } private String n() { while (tokenizer == null || !tokenizer.hasMoreTokens()) { try { tokenizer = new StringTokenizer(reader.readLine()); } catch (IOException e) { throw new RuntimeException(e); } } return tokenizer.nextToken(); } private int ni() { return Integer.parseInt(n()); } private long nl() { return Long.parseLong(n()); } private int[] readArray(int n) { int[] a = new int[n]; for (int i = 0; i < n; ++i) a[i] = ni(); return a; } } }
Java
["4 3", "6 6", "5 2"]
1 second
["java", "python", "phphp"]
NoteIn the first test there is one of the appropriate new passwords — java, because its length is equal to 4 and 3 distinct lowercase letters a, j and v are used in it.In the second test there is one of the appropriate new passwords — python, because its length is equal to 6 and it consists of 6 distinct lowercase letters.In the third test there is one of the appropriate new passwords — phphp, because its length is equal to 5 and 2 distinct lowercase letters p and h are used in it.Pay attention the condition that no two identical symbols are consecutive is correct for all appropriate passwords in tests.
Java 11
standard input
[ "implementation", "*special" ]
39f5e934bf293053246bd3faa8061c3b
The first line contains two positive integers n and k (2 ≤ n ≤ 100, 2 ≤ k ≤ min(n, 26)) — the length of the password and the number of distinct symbols in it. Pay attention that a desired new password always exists.
800
Print any password which satisfies all conditions given by Innokentiy.
standard output
PASSED
cb964a67d4efddff1067d8f510d54bf3
train_002.jsonl
1489233600
Innokentiy decides to change the password in the social net "Contact!", but he is too lazy to invent a new password by himself. That is why he needs your help. Innokentiy decides that new password should satisfy the following conditions: the length of the password must be equal to n, the password should consist only of lowercase Latin letters, the number of distinct symbols in the password must be equal to k, any two consecutive symbols in the password must be distinct. Your task is to help Innokentiy and to invent a new password which will satisfy all given conditions.
256 megabytes
import java.util.*; import java.math.*; public class Euler { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); int k = in.nextInt(); String str = ""; for (int i = 0; i < n; i++) { int x = i % k; int y = 97 + x; char c = (char) y; str += c; } System.out.println(str); } }
Java
["4 3", "6 6", "5 2"]
1 second
["java", "python", "phphp"]
NoteIn the first test there is one of the appropriate new passwords — java, because its length is equal to 4 and 3 distinct lowercase letters a, j and v are used in it.In the second test there is one of the appropriate new passwords — python, because its length is equal to 6 and it consists of 6 distinct lowercase letters.In the third test there is one of the appropriate new passwords — phphp, because its length is equal to 5 and 2 distinct lowercase letters p and h are used in it.Pay attention the condition that no two identical symbols are consecutive is correct for all appropriate passwords in tests.
Java 11
standard input
[ "implementation", "*special" ]
39f5e934bf293053246bd3faa8061c3b
The first line contains two positive integers n and k (2 ≤ n ≤ 100, 2 ≤ k ≤ min(n, 26)) — the length of the password and the number of distinct symbols in it. Pay attention that a desired new password always exists.
800
Print any password which satisfies all conditions given by Innokentiy.
standard output
PASSED
ce61c79e7a7b3fa3a7eff9636d52aeb7
train_002.jsonl
1489233600
Innokentiy decides to change the password in the social net "Contact!", but he is too lazy to invent a new password by himself. That is why he needs your help. Innokentiy decides that new password should satisfy the following conditions: the length of the password must be equal to n, the password should consist only of lowercase Latin letters, the number of distinct symbols in the password must be equal to k, any two consecutive symbols in the password must be distinct. Your task is to help Innokentiy and to invent a new password which will satisfy all given conditions.
256 megabytes
import java.util.ArrayList; import java.util.Scanner; public class Test { public static void main(String[] args) { try(Scanner input = new Scanner(System.in)) { int n = input.nextInt(); int k = input.nextInt(); System.out.print(createNewPassword(n, k)); } } public static String createNewPassword(int n, int k) { StringBuilder pass = new StringBuilder(); for (int i = 0; i < k; i++) pass.append((char)(97 + i)); for (int i = 0; i < n - k; i++) pass.append(pass.charAt(i)); return pass.toString(); } }
Java
["4 3", "6 6", "5 2"]
1 second
["java", "python", "phphp"]
NoteIn the first test there is one of the appropriate new passwords — java, because its length is equal to 4 and 3 distinct lowercase letters a, j and v are used in it.In the second test there is one of the appropriate new passwords — python, because its length is equal to 6 and it consists of 6 distinct lowercase letters.In the third test there is one of the appropriate new passwords — phphp, because its length is equal to 5 and 2 distinct lowercase letters p and h are used in it.Pay attention the condition that no two identical symbols are consecutive is correct for all appropriate passwords in tests.
Java 11
standard input
[ "implementation", "*special" ]
39f5e934bf293053246bd3faa8061c3b
The first line contains two positive integers n and k (2 ≤ n ≤ 100, 2 ≤ k ≤ min(n, 26)) — the length of the password and the number of distinct symbols in it. Pay attention that a desired new password always exists.
800
Print any password which satisfies all conditions given by Innokentiy.
standard output
PASSED
e2640f1a7fc477f93da6486fdb7f9f57
train_002.jsonl
1489233600
Innokentiy decides to change the password in the social net "Contact!", but he is too lazy to invent a new password by himself. That is why he needs your help. Innokentiy decides that new password should satisfy the following conditions: the length of the password must be equal to n, the password should consist only of lowercase Latin letters, the number of distinct symbols in the password must be equal to k, any two consecutive symbols in the password must be distinct. Your task is to help Innokentiy and to invent a new password which will satisfy all given conditions.
256 megabytes
import java.util.Scanner; public class Password { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n=sc.nextInt(); int k=sc.nextInt(); char a[]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'}; String s=""; for (int i=0;i<n;i++){ if(i<k){ s+=a[i]; }else s+=a[i%k]; } System.out.println(s); } }
Java
["4 3", "6 6", "5 2"]
1 second
["java", "python", "phphp"]
NoteIn the first test there is one of the appropriate new passwords — java, because its length is equal to 4 and 3 distinct lowercase letters a, j and v are used in it.In the second test there is one of the appropriate new passwords — python, because its length is equal to 6 and it consists of 6 distinct lowercase letters.In the third test there is one of the appropriate new passwords — phphp, because its length is equal to 5 and 2 distinct lowercase letters p and h are used in it.Pay attention the condition that no two identical symbols are consecutive is correct for all appropriate passwords in tests.
Java 11
standard input
[ "implementation", "*special" ]
39f5e934bf293053246bd3faa8061c3b
The first line contains two positive integers n and k (2 ≤ n ≤ 100, 2 ≤ k ≤ min(n, 26)) — the length of the password and the number of distinct symbols in it. Pay attention that a desired new password always exists.
800
Print any password which satisfies all conditions given by Innokentiy.
standard output
PASSED
1ed046a356356e44f18b4cb1aae23677
train_002.jsonl
1489233600
Innokentiy decides to change the password in the social net "Contact!", but he is too lazy to invent a new password by himself. That is why he needs your help. Innokentiy decides that new password should satisfy the following conditions: the length of the password must be equal to n, the password should consist only of lowercase Latin letters, the number of distinct symbols in the password must be equal to k, any two consecutive symbols in the password must be distinct. Your task is to help Innokentiy and to invent a new password which will satisfy all given conditions.
256 megabytes
import java.util.*; public class solution{ public static void main(String[] args){ Scanner sc = new Scanner(System.in); int a = sc.nextInt(); int b = sc.nextInt(); String s=""; for(int i=0;i<a;i++){ s+=(char)((int)'a'+i%b); } System.out.println(s); } }
Java
["4 3", "6 6", "5 2"]
1 second
["java", "python", "phphp"]
NoteIn the first test there is one of the appropriate new passwords — java, because its length is equal to 4 and 3 distinct lowercase letters a, j and v are used in it.In the second test there is one of the appropriate new passwords — python, because its length is equal to 6 and it consists of 6 distinct lowercase letters.In the third test there is one of the appropriate new passwords — phphp, because its length is equal to 5 and 2 distinct lowercase letters p and h are used in it.Pay attention the condition that no two identical symbols are consecutive is correct for all appropriate passwords in tests.
Java 11
standard input
[ "implementation", "*special" ]
39f5e934bf293053246bd3faa8061c3b
The first line contains two positive integers n and k (2 ≤ n ≤ 100, 2 ≤ k ≤ min(n, 26)) — the length of the password and the number of distinct symbols in it. Pay attention that a desired new password always exists.
800
Print any password which satisfies all conditions given by Innokentiy.
standard output
PASSED
496d34b09c9812212da69a42846a1c84
train_002.jsonl
1489233600
Innokentiy decides to change the password in the social net "Contact!", but he is too lazy to invent a new password by himself. That is why he needs your help. Innokentiy decides that new password should satisfy the following conditions: the length of the password must be equal to n, the password should consist only of lowercase Latin letters, the number of distinct symbols in the password must be equal to k, any two consecutive symbols in the password must be distinct. Your task is to help Innokentiy and to invent a new password which will satisfy all given conditions.
256 megabytes
import java.util.Scanner; public class practice{ static Scanner sc = new Scanner(System.in); public static String function(int n,int k) { String s=""; char[] sam=new char[k]; for(int i=0;i<k;++i) { sam[i]=(char) ('a'+i); } for(int i=0;i<n;++i) { s+=sam[i%k]; } return s; } public static void main(String[] args) { // TODO Auto-generated method stub int n= sc.nextInt(); int k= sc.nextInt(); System.out.println(function(n,k)); } }
Java
["4 3", "6 6", "5 2"]
1 second
["java", "python", "phphp"]
NoteIn the first test there is one of the appropriate new passwords — java, because its length is equal to 4 and 3 distinct lowercase letters a, j and v are used in it.In the second test there is one of the appropriate new passwords — python, because its length is equal to 6 and it consists of 6 distinct lowercase letters.In the third test there is one of the appropriate new passwords — phphp, because its length is equal to 5 and 2 distinct lowercase letters p and h are used in it.Pay attention the condition that no two identical symbols are consecutive is correct for all appropriate passwords in tests.
Java 11
standard input
[ "implementation", "*special" ]
39f5e934bf293053246bd3faa8061c3b
The first line contains two positive integers n and k (2 ≤ n ≤ 100, 2 ≤ k ≤ min(n, 26)) — the length of the password and the number of distinct symbols in it. Pay attention that a desired new password always exists.
800
Print any password which satisfies all conditions given by Innokentiy.
standard output
PASSED
9658c2d079a4ec7eb0bbed8d778c3754
train_002.jsonl
1489233600
Innokentiy decides to change the password in the social net "Contact!", but he is too lazy to invent a new password by himself. That is why he needs your help. Innokentiy decides that new password should satisfy the following conditions: the length of the password must be equal to n, the password should consist only of lowercase Latin letters, the number of distinct symbols in the password must be equal to k, any two consecutive symbols in the password must be distinct. Your task is to help Innokentiy and to invent a new password which will satisfy all given conditions.
256 megabytes
//package pkg770a; import java.util.*; public class p45 { public static void main(String[] args) { // TODO Auto-generated method stub Scanner in = new Scanner(System.in); int n = in.nextInt(); int k = in.nextInt(); char c = 97 ; String s = ""; while (k>0) { s+=c; c+=1; k--; } while (s.length()<n) { s+=s; } System.out.println(s.substring(0,n)); } }
Java
["4 3", "6 6", "5 2"]
1 second
["java", "python", "phphp"]
NoteIn the first test there is one of the appropriate new passwords — java, because its length is equal to 4 and 3 distinct lowercase letters a, j and v are used in it.In the second test there is one of the appropriate new passwords — python, because its length is equal to 6 and it consists of 6 distinct lowercase letters.In the third test there is one of the appropriate new passwords — phphp, because its length is equal to 5 and 2 distinct lowercase letters p and h are used in it.Pay attention the condition that no two identical symbols are consecutive is correct for all appropriate passwords in tests.
Java 11
standard input
[ "implementation", "*special" ]
39f5e934bf293053246bd3faa8061c3b
The first line contains two positive integers n and k (2 ≤ n ≤ 100, 2 ≤ k ≤ min(n, 26)) — the length of the password and the number of distinct symbols in it. Pay attention that a desired new password always exists.
800
Print any password which satisfies all conditions given by Innokentiy.
standard output
PASSED
e1226f63052f97bdd479be14e0cab203
train_002.jsonl
1489233600
Innokentiy decides to change the password in the social net "Contact!", but he is too lazy to invent a new password by himself. That is why he needs your help. Innokentiy decides that new password should satisfy the following conditions: the length of the password must be equal to n, the password should consist only of lowercase Latin letters, the number of distinct symbols in the password must be equal to k, any two consecutive symbols in the password must be distinct. Your task is to help Innokentiy and to invent a new password which will satisfy all given conditions.
256 megabytes
import java.util.*; //import java.util.Random; public class NewPassword { public static void main(String[]args){ Scanner in=new Scanner(System.in); int n=in.nextInt(); int k=in.nextInt(); String pass=""; for(int i=97;i<97+k;i++) { pass=pass+(char)i; } if(n>k) { for(int i=0;i<n-k;i++) { pass=pass+pass.charAt(i); } } System.out.print(pass); } }
Java
["4 3", "6 6", "5 2"]
1 second
["java", "python", "phphp"]
NoteIn the first test there is one of the appropriate new passwords — java, because its length is equal to 4 and 3 distinct lowercase letters a, j and v are used in it.In the second test there is one of the appropriate new passwords — python, because its length is equal to 6 and it consists of 6 distinct lowercase letters.In the third test there is one of the appropriate new passwords — phphp, because its length is equal to 5 and 2 distinct lowercase letters p and h are used in it.Pay attention the condition that no two identical symbols are consecutive is correct for all appropriate passwords in tests.
Java 11
standard input
[ "implementation", "*special" ]
39f5e934bf293053246bd3faa8061c3b
The first line contains two positive integers n and k (2 ≤ n ≤ 100, 2 ≤ k ≤ min(n, 26)) — the length of the password and the number of distinct symbols in it. Pay attention that a desired new password always exists.
800
Print any password which satisfies all conditions given by Innokentiy.
standard output
PASSED
d3745b75798fe07a0b14c2240a2e8888
train_002.jsonl
1489233600
Innokentiy decides to change the password in the social net "Contact!", but he is too lazy to invent a new password by himself. That is why he needs your help. Innokentiy decides that new password should satisfy the following conditions: the length of the password must be equal to n, the password should consist only of lowercase Latin letters, the number of distinct symbols in the password must be equal to k, any two consecutive symbols in the password must be distinct. Your task is to help Innokentiy and to invent a new password which will satisfy all given conditions.
256 megabytes
import java.util.Scanner; public class code { public static void main(String[] args) { Scanner inp = new Scanner(System.in); int n = inp.nextInt(); int k = inp.nextInt(); int[] string = new int[k]; int base = 97; for(int i=0;i<k;i++) { string[i] = base; base++; } int passwordCount = 0; while(passwordCount<n) { for(int i=0;i<k&&passwordCount<n;i++) { System.out.print((char)string[i]); passwordCount++; } } //System.out.println(asci); } }
Java
["4 3", "6 6", "5 2"]
1 second
["java", "python", "phphp"]
NoteIn the first test there is one of the appropriate new passwords — java, because its length is equal to 4 and 3 distinct lowercase letters a, j and v are used in it.In the second test there is one of the appropriate new passwords — python, because its length is equal to 6 and it consists of 6 distinct lowercase letters.In the third test there is one of the appropriate new passwords — phphp, because its length is equal to 5 and 2 distinct lowercase letters p and h are used in it.Pay attention the condition that no two identical symbols are consecutive is correct for all appropriate passwords in tests.
Java 11
standard input
[ "implementation", "*special" ]
39f5e934bf293053246bd3faa8061c3b
The first line contains two positive integers n and k (2 ≤ n ≤ 100, 2 ≤ k ≤ min(n, 26)) — the length of the password and the number of distinct symbols in it. Pay attention that a desired new password always exists.
800
Print any password which satisfies all conditions given by Innokentiy.
standard output
PASSED
344bb9785bc15eff722c05d94fdda52a
train_002.jsonl
1489233600
Innokentiy decides to change the password in the social net "Contact!", but he is too lazy to invent a new password by himself. That is why he needs your help. Innokentiy decides that new password should satisfy the following conditions: the length of the password must be equal to n, the password should consist only of lowercase Latin letters, the number of distinct symbols in the password must be equal to k, any two consecutive symbols in the password must be distinct. Your task is to help Innokentiy and to invent a new password which will satisfy all given conditions.
256 megabytes
import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.Scanner; public class Problems { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n , k ; n =in.nextInt(); k = in.nextInt(); String s =""; for (int i=0; i<n; i++) { s+=(char)(97+i%k); } System.out.println(s); } }
Java
["4 3", "6 6", "5 2"]
1 second
["java", "python", "phphp"]
NoteIn the first test there is one of the appropriate new passwords — java, because its length is equal to 4 and 3 distinct lowercase letters a, j and v are used in it.In the second test there is one of the appropriate new passwords — python, because its length is equal to 6 and it consists of 6 distinct lowercase letters.In the third test there is one of the appropriate new passwords — phphp, because its length is equal to 5 and 2 distinct lowercase letters p and h are used in it.Pay attention the condition that no two identical symbols are consecutive is correct for all appropriate passwords in tests.
Java 11
standard input
[ "implementation", "*special" ]
39f5e934bf293053246bd3faa8061c3b
The first line contains two positive integers n and k (2 ≤ n ≤ 100, 2 ≤ k ≤ min(n, 26)) — the length of the password and the number of distinct symbols in it. Pay attention that a desired new password always exists.
800
Print any password which satisfies all conditions given by Innokentiy.
standard output
PASSED
bf44542058b6dc0ced3b14029cfecbde
train_002.jsonl
1489233600
Innokentiy decides to change the password in the social net "Contact!", but he is too lazy to invent a new password by himself. That is why he needs your help. Innokentiy decides that new password should satisfy the following conditions: the length of the password must be equal to n, the password should consist only of lowercase Latin letters, the number of distinct symbols in the password must be equal to k, any two consecutive symbols in the password must be distinct. Your task is to help Innokentiy and to invent a new password which will satisfy all given conditions.
256 megabytes
import java.util.Arrays; import java.util.Scanner; import java.util.Stack; public class Code { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int k = sc.nextInt(); int a = (int)'a'; for(int i = 0, j = 0; i < n; i++){ char b = (char) (a+j); System.out.print(b); if(j < k-1) j++; else j--; } sc.close(); } }
Java
["4 3", "6 6", "5 2"]
1 second
["java", "python", "phphp"]
NoteIn the first test there is one of the appropriate new passwords — java, because its length is equal to 4 and 3 distinct lowercase letters a, j and v are used in it.In the second test there is one of the appropriate new passwords — python, because its length is equal to 6 and it consists of 6 distinct lowercase letters.In the third test there is one of the appropriate new passwords — phphp, because its length is equal to 5 and 2 distinct lowercase letters p and h are used in it.Pay attention the condition that no two identical symbols are consecutive is correct for all appropriate passwords in tests.
Java 11
standard input
[ "implementation", "*special" ]
39f5e934bf293053246bd3faa8061c3b
The first line contains two positive integers n and k (2 ≤ n ≤ 100, 2 ≤ k ≤ min(n, 26)) — the length of the password and the number of distinct symbols in it. Pay attention that a desired new password always exists.
800
Print any password which satisfies all conditions given by Innokentiy.
standard output
PASSED
d3c2f433b3c2d9fa277c654b42937e25
train_002.jsonl
1489233600
Innokentiy decides to change the password in the social net "Contact!", but he is too lazy to invent a new password by himself. That is why he needs your help. Innokentiy decides that new password should satisfy the following conditions: the length of the password must be equal to n, the password should consist only of lowercase Latin letters, the number of distinct symbols in the password must be equal to k, any two consecutive symbols in the password must be distinct. Your task is to help Innokentiy and to invent a new password which will satisfy all given conditions.
256 megabytes
/* Jai Shree Ram */ import java.math.*; import java.io.*; import java.util.*; public class JAVA { public static void main(String[] args) throws Exception{ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String str[] = br.readLine().trim().split("\\s+"); int n = Integer.parseInt(str[0]); int k = Integer.parseInt(str[1]); String sb = new StringBuffer("abcdefghijklmnopqrstuvwxyz").substring(0 , k); int rem = n / k; StringBuffer sb1 = new StringBuffer(); for(int i = 0; i <= rem; i++) { sb1.append(sb); } System.out.println(sb1.substring(0 , n)); } }
Java
["4 3", "6 6", "5 2"]
1 second
["java", "python", "phphp"]
NoteIn the first test there is one of the appropriate new passwords — java, because its length is equal to 4 and 3 distinct lowercase letters a, j and v are used in it.In the second test there is one of the appropriate new passwords — python, because its length is equal to 6 and it consists of 6 distinct lowercase letters.In the third test there is one of the appropriate new passwords — phphp, because its length is equal to 5 and 2 distinct lowercase letters p and h are used in it.Pay attention the condition that no two identical symbols are consecutive is correct for all appropriate passwords in tests.
Java 11
standard input
[ "implementation", "*special" ]
39f5e934bf293053246bd3faa8061c3b
The first line contains two positive integers n and k (2 ≤ n ≤ 100, 2 ≤ k ≤ min(n, 26)) — the length of the password and the number of distinct symbols in it. Pay attention that a desired new password always exists.
800
Print any password which satisfies all conditions given by Innokentiy.
standard output
PASSED
e2811551cd66e93cc5a7f8dd270ab3e4
train_002.jsonl
1489233600
Innokentiy decides to change the password in the social net "Contact!", but he is too lazy to invent a new password by himself. That is why he needs your help. Innokentiy decides that new password should satisfy the following conditions: the length of the password must be equal to n, the password should consist only of lowercase Latin letters, the number of distinct symbols in the password must be equal to k, any two consecutive symbols in the password must be distinct. Your task is to help Innokentiy and to invent a new password which will satisfy all given conditions.
256 megabytes
import java.util.Scanner; public class NewPassword { public static void main(String[] args) { Scanner input = new Scanner(System.in); int n = input.nextInt(); int k = input.nextInt(); while (n > 0) { for (int i = 0; i < k; i++) { System.out.printf("%c", 97 + i); n--; if (n == 0) break; } } input.close(); } }
Java
["4 3", "6 6", "5 2"]
1 second
["java", "python", "phphp"]
NoteIn the first test there is one of the appropriate new passwords — java, because its length is equal to 4 and 3 distinct lowercase letters a, j and v are used in it.In the second test there is one of the appropriate new passwords — python, because its length is equal to 6 and it consists of 6 distinct lowercase letters.In the third test there is one of the appropriate new passwords — phphp, because its length is equal to 5 and 2 distinct lowercase letters p and h are used in it.Pay attention the condition that no two identical symbols are consecutive is correct for all appropriate passwords in tests.
Java 11
standard input
[ "implementation", "*special" ]
39f5e934bf293053246bd3faa8061c3b
The first line contains two positive integers n and k (2 ≤ n ≤ 100, 2 ≤ k ≤ min(n, 26)) — the length of the password and the number of distinct symbols in it. Pay attention that a desired new password always exists.
800
Print any password which satisfies all conditions given by Innokentiy.
standard output
PASSED
664c6ec6d22d48d0aeb0c0970b5e32f1
train_002.jsonl
1489233600
Innokentiy decides to change the password in the social net "Contact!", but he is too lazy to invent a new password by himself. That is why he needs your help. Innokentiy decides that new password should satisfy the following conditions: the length of the password must be equal to n, the password should consist only of lowercase Latin letters, the number of distinct symbols in the password must be equal to k, any two consecutive symbols in the password must be distinct. Your task is to help Innokentiy and to invent a new password which will satisfy all given conditions.
256 megabytes
import java.util.Scanner; //import java.lang.Math; public class new_password { public static void main(String[] args) { solve(); } static void solve() { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int k = sc.nextInt(); String pass = ""; for (int i = 0; i < n; i ++) { int repeat = i % k; pass += (char)('a' + repeat); } System.out.println(pass); sc.close(); } }
Java
["4 3", "6 6", "5 2"]
1 second
["java", "python", "phphp"]
NoteIn the first test there is one of the appropriate new passwords — java, because its length is equal to 4 and 3 distinct lowercase letters a, j and v are used in it.In the second test there is one of the appropriate new passwords — python, because its length is equal to 6 and it consists of 6 distinct lowercase letters.In the third test there is one of the appropriate new passwords — phphp, because its length is equal to 5 and 2 distinct lowercase letters p and h are used in it.Pay attention the condition that no two identical symbols are consecutive is correct for all appropriate passwords in tests.
Java 11
standard input
[ "implementation", "*special" ]
39f5e934bf293053246bd3faa8061c3b
The first line contains two positive integers n and k (2 ≤ n ≤ 100, 2 ≤ k ≤ min(n, 26)) — the length of the password and the number of distinct symbols in it. Pay attention that a desired new password always exists.
800
Print any password which satisfies all conditions given by Innokentiy.
standard output
PASSED
eeea6ca5c95cb3c64412ad257311c6fc
train_002.jsonl
1489233600
Innokentiy decides to change the password in the social net "Contact!", but he is too lazy to invent a new password by himself. That is why he needs your help. Innokentiy decides that new password should satisfy the following conditions: the length of the password must be equal to n, the password should consist only of lowercase Latin letters, the number of distinct symbols in the password must be equal to k, any two consecutive symbols in the password must be distinct. Your task is to help Innokentiy and to invent a new password which will satisfy all given conditions.
256 megabytes
import java.util.*; public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); int k = in.nextInt(); String str =""; for(int i=0;i<n;i++){ str+= (char)((int)'a'+(i%k)); } System.out.println(str); } }
Java
["4 3", "6 6", "5 2"]
1 second
["java", "python", "phphp"]
NoteIn the first test there is one of the appropriate new passwords — java, because its length is equal to 4 and 3 distinct lowercase letters a, j and v are used in it.In the second test there is one of the appropriate new passwords — python, because its length is equal to 6 and it consists of 6 distinct lowercase letters.In the third test there is one of the appropriate new passwords — phphp, because its length is equal to 5 and 2 distinct lowercase letters p and h are used in it.Pay attention the condition that no two identical symbols are consecutive is correct for all appropriate passwords in tests.
Java 11
standard input
[ "implementation", "*special" ]
39f5e934bf293053246bd3faa8061c3b
The first line contains two positive integers n and k (2 ≤ n ≤ 100, 2 ≤ k ≤ min(n, 26)) — the length of the password and the number of distinct symbols in it. Pay attention that a desired new password always exists.
800
Print any password which satisfies all conditions given by Innokentiy.
standard output
PASSED
b2f37292e76a2d1690ebf0ceb2938e2c
train_002.jsonl
1489233600
Innokentiy decides to change the password in the social net "Contact!", but he is too lazy to invent a new password by himself. That is why he needs your help. Innokentiy decides that new password should satisfy the following conditions: the length of the password must be equal to n, the password should consist only of lowercase Latin letters, the number of distinct symbols in the password must be equal to k, any two consecutive symbols in the password must be distinct. Your task is to help Innokentiy and to invent a new password which will satisfy all given conditions.
256 megabytes
import java.util.Scanner; public class ProblemSolving { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int k = sc.nextInt(); String password =""; String alphapet="abcdefghijklmnopqrstuvwxyz"; int j=0; for(int i =0;i<n;i++) { if(k>=1) { password +=alphapet.charAt(i); } if(k--<1) { password+=password.charAt(j); j++; } } System.out.println(password); } }
Java
["4 3", "6 6", "5 2"]
1 second
["java", "python", "phphp"]
NoteIn the first test there is one of the appropriate new passwords — java, because its length is equal to 4 and 3 distinct lowercase letters a, j and v are used in it.In the second test there is one of the appropriate new passwords — python, because its length is equal to 6 and it consists of 6 distinct lowercase letters.In the third test there is one of the appropriate new passwords — phphp, because its length is equal to 5 and 2 distinct lowercase letters p and h are used in it.Pay attention the condition that no two identical symbols are consecutive is correct for all appropriate passwords in tests.
Java 11
standard input
[ "implementation", "*special" ]
39f5e934bf293053246bd3faa8061c3b
The first line contains two positive integers n and k (2 ≤ n ≤ 100, 2 ≤ k ≤ min(n, 26)) — the length of the password and the number of distinct symbols in it. Pay attention that a desired new password always exists.
800
Print any password which satisfies all conditions given by Innokentiy.
standard output
PASSED
d80c4d57489df2fbdce3dc5a82f6c473
train_002.jsonl
1489233600
Innokentiy decides to change the password in the social net "Contact!", but he is too lazy to invent a new password by himself. That is why he needs your help. Innokentiy decides that new password should satisfy the following conditions: the length of the password must be equal to n, the password should consist only of lowercase Latin letters, the number of distinct symbols in the password must be equal to k, any two consecutive symbols in the password must be distinct. Your task is to help Innokentiy and to invent a new password which will satisfy all given conditions.
256 megabytes
import java.util.Scanner; import java.util.Set; public class ProblemSolving { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int k = sc.nextInt(); String password =""; String alphapet="abcdefghijklmnopqrstuvwxyz"; int j=0; for(int i =0;i<n;i++) { password+=(char)((i%k)+'a'); } System.out.println(password); } }
Java
["4 3", "6 6", "5 2"]
1 second
["java", "python", "phphp"]
NoteIn the first test there is one of the appropriate new passwords — java, because its length is equal to 4 and 3 distinct lowercase letters a, j and v are used in it.In the second test there is one of the appropriate new passwords — python, because its length is equal to 6 and it consists of 6 distinct lowercase letters.In the third test there is one of the appropriate new passwords — phphp, because its length is equal to 5 and 2 distinct lowercase letters p and h are used in it.Pay attention the condition that no two identical symbols are consecutive is correct for all appropriate passwords in tests.
Java 11
standard input
[ "implementation", "*special" ]
39f5e934bf293053246bd3faa8061c3b
The first line contains two positive integers n and k (2 ≤ n ≤ 100, 2 ≤ k ≤ min(n, 26)) — the length of the password and the number of distinct symbols in it. Pay attention that a desired new password always exists.
800
Print any password which satisfies all conditions given by Innokentiy.
standard output
PASSED
3da76086dc3af074bf4d473bd796d7d0
train_002.jsonl
1489233600
Innokentiy decides to change the password in the social net "Contact!", but he is too lazy to invent a new password by himself. That is why he needs your help. Innokentiy decides that new password should satisfy the following conditions: the length of the password must be equal to n, the password should consist only of lowercase Latin letters, the number of distinct symbols in the password must be equal to k, any two consecutive symbols in the password must be distinct. Your task is to help Innokentiy and to invent a new password which will satisfy all given conditions.
256 megabytes
import java.util.Scanner; /** * * @author aso */ public class Problem27 { /** * @param args the command line arguments */ public static void main(String[] args) { Scanner in = new Scanner(System.in); char[] c = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'}; int lenth = in.nextInt(); int rebet = in.nextInt(); int s = rebet ; String res = ""; int coun = 0; for (int x = 0; x < lenth; x++) { if (x == rebet) { rebet = rebet+s; coun = 0; } res += c[coun]; coun++; } System.out.println(res); } }
Java
["4 3", "6 6", "5 2"]
1 second
["java", "python", "phphp"]
NoteIn the first test there is one of the appropriate new passwords — java, because its length is equal to 4 and 3 distinct lowercase letters a, j and v are used in it.In the second test there is one of the appropriate new passwords — python, because its length is equal to 6 and it consists of 6 distinct lowercase letters.In the third test there is one of the appropriate new passwords — phphp, because its length is equal to 5 and 2 distinct lowercase letters p and h are used in it.Pay attention the condition that no two identical symbols are consecutive is correct for all appropriate passwords in tests.
Java 11
standard input
[ "implementation", "*special" ]
39f5e934bf293053246bd3faa8061c3b
The first line contains two positive integers n and k (2 ≤ n ≤ 100, 2 ≤ k ≤ min(n, 26)) — the length of the password and the number of distinct symbols in it. Pay attention that a desired new password always exists.
800
Print any password which satisfies all conditions given by Innokentiy.
standard output
PASSED
26f67308152ff742d27d8a01d6dfe03d
train_002.jsonl
1489233600
Innokentiy decides to change the password in the social net "Contact!", but he is too lazy to invent a new password by himself. That is why he needs your help. Innokentiy decides that new password should satisfy the following conditions: the length of the password must be equal to n, the password should consist only of lowercase Latin letters, the number of distinct symbols in the password must be equal to k, any two consecutive symbols in the password must be distinct. Your task is to help Innokentiy and to invent a new password which will satisfy all given conditions.
256 megabytes
import java.util.*; public class Hello { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int x = scanner.nextInt(); int y = scanner.nextInt(); StringBuffer s = new StringBuffer(); int m = 97; int c = 0; for(int i = 0; i < x; i++){ if (c < y){ s.append((char) m); c++; m++; } else { s.append((char) m); } if (c == y){ m = 97; c = 0; } } System.out.println(s); } }
Java
["4 3", "6 6", "5 2"]
1 second
["java", "python", "phphp"]
NoteIn the first test there is one of the appropriate new passwords — java, because its length is equal to 4 and 3 distinct lowercase letters a, j and v are used in it.In the second test there is one of the appropriate new passwords — python, because its length is equal to 6 and it consists of 6 distinct lowercase letters.In the third test there is one of the appropriate new passwords — phphp, because its length is equal to 5 and 2 distinct lowercase letters p and h are used in it.Pay attention the condition that no two identical symbols are consecutive is correct for all appropriate passwords in tests.
Java 11
standard input
[ "implementation", "*special" ]
39f5e934bf293053246bd3faa8061c3b
The first line contains two positive integers n and k (2 ≤ n ≤ 100, 2 ≤ k ≤ min(n, 26)) — the length of the password and the number of distinct symbols in it. Pay attention that a desired new password always exists.
800
Print any password which satisfies all conditions given by Innokentiy.
standard output
PASSED
17ee3dd42bb2caa9ebd2b87b50b02a7d
train_002.jsonl
1489233600
Innokentiy decides to change the password in the social net "Contact!", but he is too lazy to invent a new password by himself. That is why he needs your help. Innokentiy decides that new password should satisfy the following conditions: the length of the password must be equal to n, the password should consist only of lowercase Latin letters, the number of distinct symbols in the password must be equal to k, any two consecutive symbols in the password must be distinct. Your task is to help Innokentiy and to invent a new password which will satisfy all given conditions.
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; public class Main { 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 in = new FastReader(); int l = in.nextInt(); int dist = in.nextInt(); char[] chars = new char[dist]; for (int i = 0; i < dist; i++) { chars[i] = (char) (i + 97); } for (int i = 0; i < l; i++) { System.out.print(chars[i % dist]); } } }
Java
["4 3", "6 6", "5 2"]
1 second
["java", "python", "phphp"]
NoteIn the first test there is one of the appropriate new passwords — java, because its length is equal to 4 and 3 distinct lowercase letters a, j and v are used in it.In the second test there is one of the appropriate new passwords — python, because its length is equal to 6 and it consists of 6 distinct lowercase letters.In the third test there is one of the appropriate new passwords — phphp, because its length is equal to 5 and 2 distinct lowercase letters p and h are used in it.Pay attention the condition that no two identical symbols are consecutive is correct for all appropriate passwords in tests.
Java 11
standard input
[ "implementation", "*special" ]
39f5e934bf293053246bd3faa8061c3b
The first line contains two positive integers n and k (2 ≤ n ≤ 100, 2 ≤ k ≤ min(n, 26)) — the length of the password and the number of distinct symbols in it. Pay attention that a desired new password always exists.
800
Print any password which satisfies all conditions given by Innokentiy.
standard output
PASSED
b6a2ea8ea1ece16eea0d5452a0f01762
train_002.jsonl
1489233600
Innokentiy decides to change the password in the social net "Contact!", but he is too lazy to invent a new password by himself. That is why he needs your help. Innokentiy decides that new password should satisfy the following conditions: the length of the password must be equal to n, the password should consist only of lowercase Latin letters, the number of distinct symbols in the password must be equal to k, any two consecutive symbols in the password must be distinct. Your task is to help Innokentiy and to invent a new password which will satisfy all given conditions.
256 megabytes
import java.util.Arrays; import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); int k = in.nextInt(); char[] pass = new char[n]; char[] cryp = new char[k]; for (int i = 97; i < 97+k; i++){ cryp[i-97] = (char)i; } int i = 0; int j = 0; while (i < n ){ if(j >= k){ j = 0; } pass[i] = cryp[j]; i++; j++; } for (int x = 0; x < pass.length; x++){ System.out.print(pass[x]); } } }
Java
["4 3", "6 6", "5 2"]
1 second
["java", "python", "phphp"]
NoteIn the first test there is one of the appropriate new passwords — java, because its length is equal to 4 and 3 distinct lowercase letters a, j and v are used in it.In the second test there is one of the appropriate new passwords — python, because its length is equal to 6 and it consists of 6 distinct lowercase letters.In the third test there is one of the appropriate new passwords — phphp, because its length is equal to 5 and 2 distinct lowercase letters p and h are used in it.Pay attention the condition that no two identical symbols are consecutive is correct for all appropriate passwords in tests.
Java 11
standard input
[ "implementation", "*special" ]
39f5e934bf293053246bd3faa8061c3b
The first line contains two positive integers n and k (2 ≤ n ≤ 100, 2 ≤ k ≤ min(n, 26)) — the length of the password and the number of distinct symbols in it. Pay attention that a desired new password always exists.
800
Print any password which satisfies all conditions given by Innokentiy.
standard output
PASSED
04c09bf5547ebe75aa920c340535527d
train_002.jsonl
1489233600
Innokentiy decides to change the password in the social net "Contact!", but he is too lazy to invent a new password by himself. That is why he needs your help. Innokentiy decides that new password should satisfy the following conditions: the length of the password must be equal to n, the password should consist only of lowercase Latin letters, the number of distinct symbols in the password must be equal to k, any two consecutive symbols in the password must be distinct. Your task is to help Innokentiy and to invent a new password which will satisfy all given conditions.
256 megabytes
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner inp=new Scanner(System.in); int lenght=inp.nextInt(); int words=inp.nextInt(); char array[]=new char[words]; int c=0; for (int i =97 ; i <97+words; i++) { char a=(char)i; array [c]=a; c++; } for(int i=0;i<lenght;i++){ if(i==words){ i=0; lenght-=words; System.out.print(array[i]); } else System.out.print(array[i]); } } }
Java
["4 3", "6 6", "5 2"]
1 second
["java", "python", "phphp"]
NoteIn the first test there is one of the appropriate new passwords — java, because its length is equal to 4 and 3 distinct lowercase letters a, j and v are used in it.In the second test there is one of the appropriate new passwords — python, because its length is equal to 6 and it consists of 6 distinct lowercase letters.In the third test there is one of the appropriate new passwords — phphp, because its length is equal to 5 and 2 distinct lowercase letters p and h are used in it.Pay attention the condition that no two identical symbols are consecutive is correct for all appropriate passwords in tests.
Java 11
standard input
[ "implementation", "*special" ]
39f5e934bf293053246bd3faa8061c3b
The first line contains two positive integers n and k (2 ≤ n ≤ 100, 2 ≤ k ≤ min(n, 26)) — the length of the password and the number of distinct symbols in it. Pay attention that a desired new password always exists.
800
Print any password which satisfies all conditions given by Innokentiy.
standard output
PASSED
63d884f62a7f2caa507db9988073366e
train_002.jsonl
1489233600
Innokentiy decides to change the password in the social net "Contact!", but he is too lazy to invent a new password by himself. That is why he needs your help. Innokentiy decides that new password should satisfy the following conditions: the length of the password must be equal to n, the password should consist only of lowercase Latin letters, the number of distinct symbols in the password must be equal to k, any two consecutive symbols in the password must be distinct. Your task is to help Innokentiy and to invent a new password which will satisfy all given conditions.
256 megabytes
import java.util.*; import java.io.*; import java.lang.*; public class c { 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') break; 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 scn = new Reader(); StringBuilder res = new StringBuilder(); int n = scn.nextInt(); int k = scn.nextInt(); for (int i = 0; i < n; i++) { char ch = (char) ((i % k) + 97); res.append(ch); } System.out.print(res); } }
Java
["4 3", "6 6", "5 2"]
1 second
["java", "python", "phphp"]
NoteIn the first test there is one of the appropriate new passwords — java, because its length is equal to 4 and 3 distinct lowercase letters a, j and v are used in it.In the second test there is one of the appropriate new passwords — python, because its length is equal to 6 and it consists of 6 distinct lowercase letters.In the third test there is one of the appropriate new passwords — phphp, because its length is equal to 5 and 2 distinct lowercase letters p and h are used in it.Pay attention the condition that no two identical symbols are consecutive is correct for all appropriate passwords in tests.
Java 11
standard input
[ "implementation", "*special" ]
39f5e934bf293053246bd3faa8061c3b
The first line contains two positive integers n and k (2 ≤ n ≤ 100, 2 ≤ k ≤ min(n, 26)) — the length of the password and the number of distinct symbols in it. Pay attention that a desired new password always exists.
800
Print any password which satisfies all conditions given by Innokentiy.
standard output
PASSED
76da159180519c74414a5484e023be70
train_002.jsonl
1489233600
Innokentiy decides to change the password in the social net "Contact!", but he is too lazy to invent a new password by himself. That is why he needs your help. Innokentiy decides that new password should satisfy the following conditions: the length of the password must be equal to n, the password should consist only of lowercase Latin letters, the number of distinct symbols in the password must be equal to k, any two consecutive symbols in the password must be distinct. Your task is to help Innokentiy and to invent a new password which will satisfy all given conditions.
256 megabytes
import java.util.Scanner; public class Password { public static void main(String args[]) { Scanner sc = new Scanner(System.in); String a = ""; for(char i='a';i<='z';i++) { a+=i; } int len = sc.nextInt(); int ch = sc.nextInt(); String b = ""; for(int i=0;i<len;i++) { b+=a.substring(0,ch); } b = b.substring(0,len); System.out.println(b); } }
Java
["4 3", "6 6", "5 2"]
1 second
["java", "python", "phphp"]
NoteIn the first test there is one of the appropriate new passwords — java, because its length is equal to 4 and 3 distinct lowercase letters a, j and v are used in it.In the second test there is one of the appropriate new passwords — python, because its length is equal to 6 and it consists of 6 distinct lowercase letters.In the third test there is one of the appropriate new passwords — phphp, because its length is equal to 5 and 2 distinct lowercase letters p and h are used in it.Pay attention the condition that no two identical symbols are consecutive is correct for all appropriate passwords in tests.
Java 11
standard input
[ "implementation", "*special" ]
39f5e934bf293053246bd3faa8061c3b
The first line contains two positive integers n and k (2 ≤ n ≤ 100, 2 ≤ k ≤ min(n, 26)) — the length of the password and the number of distinct symbols in it. Pay attention that a desired new password always exists.
800
Print any password which satisfies all conditions given by Innokentiy.
standard output
PASSED
61de68878ca052848abab368d88f66c9
train_002.jsonl
1489233600
Innokentiy decides to change the password in the social net "Contact!", but he is too lazy to invent a new password by himself. That is why he needs your help. Innokentiy decides that new password should satisfy the following conditions: the length of the password must be equal to n, the password should consist only of lowercase Latin letters, the number of distinct symbols in the password must be equal to k, any two consecutive symbols in the password must be distinct. Your task is to help Innokentiy and to invent a new password which will satisfy all given conditions.
256 megabytes
import java.util.*; import java.io.*; public class a { BufferedReader br; PrintWriter out; StringTokenizer st; public a() throws Exception { br = new BufferedReader(new InputStreamReader(System.in)); out = new PrintWriter(System.out); } public void solve() throws IOException { int nums[] = readArray(2); int j = 0; for (int i=0; i<nums[0]; i++) { char c = (char)('a'+j); j++; j%=nums[1]; out.print(c); } out.println(); out.flush(); } public int[] readArray(int n) throws IOException{ st = new StringTokenizer(br.readLine()); int[] nums = new int[n]; for (int i=0; i<n; i++) nums[i] = Integer.parseInt(st.nextToken()); return nums; } public static void main(String[] args) throws Exception { new a().solve(); } }
Java
["4 3", "6 6", "5 2"]
1 second
["java", "python", "phphp"]
NoteIn the first test there is one of the appropriate new passwords — java, because its length is equal to 4 and 3 distinct lowercase letters a, j and v are used in it.In the second test there is one of the appropriate new passwords — python, because its length is equal to 6 and it consists of 6 distinct lowercase letters.In the third test there is one of the appropriate new passwords — phphp, because its length is equal to 5 and 2 distinct lowercase letters p and h are used in it.Pay attention the condition that no two identical symbols are consecutive is correct for all appropriate passwords in tests.
Java 11
standard input
[ "implementation", "*special" ]
39f5e934bf293053246bd3faa8061c3b
The first line contains two positive integers n and k (2 ≤ n ≤ 100, 2 ≤ k ≤ min(n, 26)) — the length of the password and the number of distinct symbols in it. Pay attention that a desired new password always exists.
800
Print any password which satisfies all conditions given by Innokentiy.
standard output
PASSED
00f0af4ee820786b3983485561857998
train_002.jsonl
1489233600
Innokentiy decides to change the password in the social net "Contact!", but he is too lazy to invent a new password by himself. That is why he needs your help. Innokentiy decides that new password should satisfy the following conditions: the length of the password must be equal to n, the password should consist only of lowercase Latin letters, the number of distinct symbols in the password must be equal to k, any two consecutive symbols in the password must be distinct. Your task is to help Innokentiy and to invent a new password which will satisfy all given conditions.
256 megabytes
import java.util.*; import java.io.*; public class a { BufferedReader br; PrintWriter out; StringTokenizer st; public a() throws Exception { br = new BufferedReader(new InputStreamReader(System.in)); out = new PrintWriter(System.out); } public void solve() throws IOException { int nums[] = readArray(2); int j = 0; for (int i=0; i<nums[0]; i++) { char c = (char)('a'+j); j++; j%=nums[1]; out.print(c); } out.println(); out.flush(); } public int[] readArray(int n) throws IOException{ st = new StringTokenizer(br.readLine()); int[] nums = new int[n]; for (int i=0; i<n; i++) nums[i] = Integer.parseInt(st.nextToken()); return nums; } public static void main(String[] args) throws Exception { new a().solve(); } }
Java
["4 3", "6 6", "5 2"]
1 second
["java", "python", "phphp"]
NoteIn the first test there is one of the appropriate new passwords — java, because its length is equal to 4 and 3 distinct lowercase letters a, j and v are used in it.In the second test there is one of the appropriate new passwords — python, because its length is equal to 6 and it consists of 6 distinct lowercase letters.In the third test there is one of the appropriate new passwords — phphp, because its length is equal to 5 and 2 distinct lowercase letters p and h are used in it.Pay attention the condition that no two identical symbols are consecutive is correct for all appropriate passwords in tests.
Java 11
standard input
[ "implementation", "*special" ]
39f5e934bf293053246bd3faa8061c3b
The first line contains two positive integers n and k (2 ≤ n ≤ 100, 2 ≤ k ≤ min(n, 26)) — the length of the password and the number of distinct symbols in it. Pay attention that a desired new password always exists.
800
Print any password which satisfies all conditions given by Innokentiy.
standard output
PASSED
a2210f5b2c823329282560908af59b95
train_002.jsonl
1489233600
Innokentiy decides to change the password in the social net "Contact!", but he is too lazy to invent a new password by himself. That is why he needs your help. Innokentiy decides that new password should satisfy the following conditions: the length of the password must be equal to n, the password should consist only of lowercase Latin letters, the number of distinct symbols in the password must be equal to k, any two consecutive symbols in the password must be distinct. Your task is to help Innokentiy and to invent a new password which will satisfy all given conditions.
256 megabytes
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); int k = in.nextInt(); String s = ""; for (int i = 0; i < n; i++) { s += (char)((int)'a' + i % k); } System.out.println(s); } }
Java
["4 3", "6 6", "5 2"]
1 second
["java", "python", "phphp"]
NoteIn the first test there is one of the appropriate new passwords — java, because its length is equal to 4 and 3 distinct lowercase letters a, j and v are used in it.In the second test there is one of the appropriate new passwords — python, because its length is equal to 6 and it consists of 6 distinct lowercase letters.In the third test there is one of the appropriate new passwords — phphp, because its length is equal to 5 and 2 distinct lowercase letters p and h are used in it.Pay attention the condition that no two identical symbols are consecutive is correct for all appropriate passwords in tests.
Java 11
standard input
[ "implementation", "*special" ]
39f5e934bf293053246bd3faa8061c3b
The first line contains two positive integers n and k (2 ≤ n ≤ 100, 2 ≤ k ≤ min(n, 26)) — the length of the password and the number of distinct symbols in it. Pay attention that a desired new password always exists.
800
Print any password which satisfies all conditions given by Innokentiy.
standard output
PASSED
c0cfb1f0884a8190e38d33a69f14c7c2
train_002.jsonl
1489233600
Innokentiy decides to change the password in the social net "Contact!", but he is too lazy to invent a new password by himself. That is why he needs your help. Innokentiy decides that new password should satisfy the following conditions: the length of the password must be equal to n, the password should consist only of lowercase Latin letters, the number of distinct symbols in the password must be equal to k, any two consecutive symbols in the password must be distinct. Your task is to help Innokentiy and to invent a new password which will satisfy all given conditions.
256 megabytes
// Long Contest 1, Problem G import java.io.*; import java.nio.charset.Charset; import java.util.Arrays; public class Main { public static void main(String[] args) { Charset charset = Charset.forName("ascii"); FastIO rd = new FastIO(System.in, System.out, charset); int n = rd.readInt(); int k = rd.readInt(); char[] letters = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'}; String word = ""; for(int i=0; i < n; i++) { word += letters[i%k]; } System.out.println(word); } } class FastIO { public final StringBuilder cache = new StringBuilder(1 << 20); private final InputStream is; private final OutputStream os; private final Charset charset; private StringBuilder defaultStringBuf = new StringBuilder(1 << 8); private byte[] buf = new byte[1 << 13]; private int bufLen; private int bufOffset; private int next; public FastIO(InputStream is, OutputStream os, Charset charset) { this.is = is; this.os = os; this.charset = charset; } public FastIO(InputStream is, OutputStream os) { this(is, os, Charset.forName("ascii")); } private int read() { while (bufLen == bufOffset) { bufOffset = 0; try { bufLen = is.read(buf); } catch (IOException e) { throw new RuntimeException(e); } if (bufLen == -1) { return -1; } } return buf[bufOffset++]; } public void skipBlank() { while (next >= 0 && next <= 32) { next = read(); } } public int readInt() { int sign = 1; skipBlank(); if (next == '+' || next == '-') { sign = next == '+' ? 1 : -1; next = read(); } int val = 0; if (sign == 1) { while (next >= '0' && next <= '9') { val = val * 10 + next - '0'; next = read(); } } else { while (next >= '0' && next <= '9') { val = val * 10 - next + '0'; next = read(); } } return val; } public long readLong() { int sign = 1; skipBlank(); if (next == '+' || next == '-') { sign = next == '+' ? 1 : -1; next = read(); } long val = 0; if (sign == 1) { while (next >= '0' && next <= '9') { val = val * 10 + next - '0'; next = read(); } } else { while (next >= '0' && next <= '9') { val = val * 10 - next + '0'; next = read(); } } return val; } public double readDouble() { boolean sign = true; skipBlank(); if (next == '+' || next == '-') { sign = next == '+'; next = read(); } long val = 0; while (next >= '0' && next <= '9') { val = val * 10 + next - '0'; next = read(); } if (next != '.') { return sign ? val : -val; } next = read(); long radix = 1; long point = 0; while (next >= '0' && next <= '9') { point = point * 10 + next - '0'; radix = radix * 10; next = read(); } double result = val + (double) point / radix; return sign ? result : -result; } public String readString(StringBuilder builder) { skipBlank(); while (next > 32) { builder.append((char) next); next = read(); } return builder.toString(); } public String readString() { defaultStringBuf.setLength(0); return readString(defaultStringBuf); } public int readLine(char[] data, int offset) { int originalOffset = offset; while (next != -1 && next != '\n') { data[offset++] = (char) next; next = read(); } return offset - originalOffset; } public int readString(char[] data, int offset) { skipBlank(); int originalOffset = offset; while (next > 32) { data[offset++] = (char) next; next = read(); } return offset - originalOffset; } public int readString(byte[] data, int offset) { skipBlank(); int originalOffset = offset; while (next > 32) { data[offset++] = (byte) next; next = read(); } return offset - originalOffset; } public char readChar() { skipBlank(); char c = (char) next; next = read(); return c; } public void flush() { try { os.write(cache.toString().getBytes(charset)); os.flush(); cache.setLength(0); } catch (IOException e) { throw new RuntimeException(e); } } public boolean hasMore() { skipBlank(); return next != -1; } }
Java
["4 3", "6 6", "5 2"]
1 second
["java", "python", "phphp"]
NoteIn the first test there is one of the appropriate new passwords — java, because its length is equal to 4 and 3 distinct lowercase letters a, j and v are used in it.In the second test there is one of the appropriate new passwords — python, because its length is equal to 6 and it consists of 6 distinct lowercase letters.In the third test there is one of the appropriate new passwords — phphp, because its length is equal to 5 and 2 distinct lowercase letters p and h are used in it.Pay attention the condition that no two identical symbols are consecutive is correct for all appropriate passwords in tests.
Java 11
standard input
[ "implementation", "*special" ]
39f5e934bf293053246bd3faa8061c3b
The first line contains two positive integers n and k (2 ≤ n ≤ 100, 2 ≤ k ≤ min(n, 26)) — the length of the password and the number of distinct symbols in it. Pay attention that a desired new password always exists.
800
Print any password which satisfies all conditions given by Innokentiy.
standard output
PASSED
3141b74a781e1ca88597464dc7720a25
train_002.jsonl
1489233600
Innokentiy decides to change the password in the social net "Contact!", but he is too lazy to invent a new password by himself. That is why he needs your help. Innokentiy decides that new password should satisfy the following conditions: the length of the password must be equal to n, the password should consist only of lowercase Latin letters, the number of distinct symbols in the password must be equal to k, any two consecutive symbols in the password must be distinct. Your task is to help Innokentiy and to invent a new password which will satisfy all given conditions.
256 megabytes
import java.util.*; public class aaa { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int n = scan.nextInt(); int k = scan.nextInt(); String s = ""; char x = 'a'; for(int i =0;i<k;i++) { s+= x; x++; } for(int j =0, i =0;i<n-k;i++,j++) { s+=s.charAt(j); if(j==k) { j=0; } } System.out.println(s); } }
Java
["4 3", "6 6", "5 2"]
1 second
["java", "python", "phphp"]
NoteIn the first test there is one of the appropriate new passwords — java, because its length is equal to 4 and 3 distinct lowercase letters a, j and v are used in it.In the second test there is one of the appropriate new passwords — python, because its length is equal to 6 and it consists of 6 distinct lowercase letters.In the third test there is one of the appropriate new passwords — phphp, because its length is equal to 5 and 2 distinct lowercase letters p and h are used in it.Pay attention the condition that no two identical symbols are consecutive is correct for all appropriate passwords in tests.
Java 11
standard input
[ "implementation", "*special" ]
39f5e934bf293053246bd3faa8061c3b
The first line contains two positive integers n and k (2 ≤ n ≤ 100, 2 ≤ k ≤ min(n, 26)) — the length of the password and the number of distinct symbols in it. Pay attention that a desired new password always exists.
800
Print any password which satisfies all conditions given by Innokentiy.
standard output
PASSED
2a5eca247f78b62d498ca2c07d4e2281
train_002.jsonl
1489233600
Innokentiy decides to change the password in the social net "Contact!", but he is too lazy to invent a new password by himself. That is why he needs your help. Innokentiy decides that new password should satisfy the following conditions: the length of the password must be equal to n, the password should consist only of lowercase Latin letters, the number of distinct symbols in the password must be equal to k, any two consecutive symbols in the password must be distinct. Your task is to help Innokentiy and to invent a new password which will satisfy all given conditions.
256 megabytes
import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.Scanner; //juicer public class App { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int ch = sc.nextInt(), count = 0; sc.close(); char[] arr = new char[ch]; while (count < ch) { int random = (int) (Math.random() * (122 - 97 + 1) + 97); if (indexOf(arr, (char) random) < 0) { arr[count] = (char) random; count++; } } count = 0; for (int i = 0; i < n; i++) { if (count >= ch) { count = 0; } System.out.print(arr[count]); count++; } } public static int indexOf(char[] arr, char v) { int index = -1; for (int i = 0; i < arr.length; i++) { if (arr[i] == v) { index = i; } } return index; } }
Java
["4 3", "6 6", "5 2"]
1 second
["java", "python", "phphp"]
NoteIn the first test there is one of the appropriate new passwords — java, because its length is equal to 4 and 3 distinct lowercase letters a, j and v are used in it.In the second test there is one of the appropriate new passwords — python, because its length is equal to 6 and it consists of 6 distinct lowercase letters.In the third test there is one of the appropriate new passwords — phphp, because its length is equal to 5 and 2 distinct lowercase letters p and h are used in it.Pay attention the condition that no two identical symbols are consecutive is correct for all appropriate passwords in tests.
Java 11
standard input
[ "implementation", "*special" ]
39f5e934bf293053246bd3faa8061c3b
The first line contains two positive integers n and k (2 ≤ n ≤ 100, 2 ≤ k ≤ min(n, 26)) — the length of the password and the number of distinct symbols in it. Pay attention that a desired new password always exists.
800
Print any password which satisfies all conditions given by Innokentiy.
standard output
PASSED
529b95e658b61131bbc5a9136e870895
train_002.jsonl
1489233600
Innokentiy decides to change the password in the social net "Contact!", but he is too lazy to invent a new password by himself. That is why he needs your help. Innokentiy decides that new password should satisfy the following conditions: the length of the password must be equal to n, the password should consist only of lowercase Latin letters, the number of distinct symbols in the password must be equal to k, any two consecutive symbols in the password must be distinct. Your task is to help Innokentiy and to invent a new password which will satisfy all given conditions.
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Scanner; /** * Built using CHelper plug-in * Actual solution is at the top * * @author Bisoye */ public class Main { public static void main(String[] args) { InputStream inputStream = System.in; OutputStream outputStream = System.out; Scanner in = new Scanner(inputStream); PrintWriter out = new PrintWriter(outputStream); ANewPassword solver = new ANewPassword(); solver.solve(1, in, out); out.close(); } static class ANewPassword { public void solve(int testNumber, Scanner in, PrintWriter out) { int n = in.nextInt(), k = in.nextInt(); StringBuilder str = new StringBuilder(); for (int i = 0; i < Math.ceil((double) n / k); i++) { for (int j = 0; j < k; j++) { str.append((char) ('a' + j)); } } str.delete(n, str.length()); out.println(str.toString()); } } }
Java
["4 3", "6 6", "5 2"]
1 second
["java", "python", "phphp"]
NoteIn the first test there is one of the appropriate new passwords — java, because its length is equal to 4 and 3 distinct lowercase letters a, j and v are used in it.In the second test there is one of the appropriate new passwords — python, because its length is equal to 6 and it consists of 6 distinct lowercase letters.In the third test there is one of the appropriate new passwords — phphp, because its length is equal to 5 and 2 distinct lowercase letters p and h are used in it.Pay attention the condition that no two identical symbols are consecutive is correct for all appropriate passwords in tests.
Java 11
standard input
[ "implementation", "*special" ]
39f5e934bf293053246bd3faa8061c3b
The first line contains two positive integers n and k (2 ≤ n ≤ 100, 2 ≤ k ≤ min(n, 26)) — the length of the password and the number of distinct symbols in it. Pay attention that a desired new password always exists.
800
Print any password which satisfies all conditions given by Innokentiy.
standard output
PASSED
077090c84f951eb394c89c20968ddb34
train_002.jsonl
1489233600
Innokentiy decides to change the password in the social net "Contact!", but he is too lazy to invent a new password by himself. That is why he needs your help. Innokentiy decides that new password should satisfy the following conditions: the length of the password must be equal to n, the password should consist only of lowercase Latin letters, the number of distinct symbols in the password must be equal to k, any two consecutive symbols in the password must be distinct. Your task is to help Innokentiy and to invent a new password which will satisfy all given conditions.
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Scanner; /** * Built using CHelper plug-in * Actual solution is at the top * * @author Bisoye */ public class Main { public static void main(String[] args) { InputStream inputStream = System.in; OutputStream outputStream = System.out; Scanner in = new Scanner(inputStream); PrintWriter out = new PrintWriter(outputStream); ANewPassword solver = new ANewPassword(); solver.solve(1, in, out); out.close(); } static class ANewPassword { public void solve(int testNumber, Scanner in, PrintWriter out) { int n = in.nextInt(), k = in.nextInt(); StringBuilder str = new StringBuilder(); for (int j = 0; j < k; j++) { str.append((char) ('a' + j)); } int i = 0; while (str.length() < n) { str.append(str.charAt(i++)); i %= k; } out.println(str.toString()); } } }
Java
["4 3", "6 6", "5 2"]
1 second
["java", "python", "phphp"]
NoteIn the first test there is one of the appropriate new passwords — java, because its length is equal to 4 and 3 distinct lowercase letters a, j and v are used in it.In the second test there is one of the appropriate new passwords — python, because its length is equal to 6 and it consists of 6 distinct lowercase letters.In the third test there is one of the appropriate new passwords — phphp, because its length is equal to 5 and 2 distinct lowercase letters p and h are used in it.Pay attention the condition that no two identical symbols are consecutive is correct for all appropriate passwords in tests.
Java 11
standard input
[ "implementation", "*special" ]
39f5e934bf293053246bd3faa8061c3b
The first line contains two positive integers n and k (2 ≤ n ≤ 100, 2 ≤ k ≤ min(n, 26)) — the length of the password and the number of distinct symbols in it. Pay attention that a desired new password always exists.
800
Print any password which satisfies all conditions given by Innokentiy.
standard output
PASSED
ffa8d241851eecf0bfe61329461bfafd
train_002.jsonl
1489233600
Innokentiy decides to change the password in the social net "Contact!", but he is too lazy to invent a new password by himself. That is why he needs your help. Innokentiy decides that new password should satisfy the following conditions: the length of the password must be equal to n, the password should consist only of lowercase Latin letters, the number of distinct symbols in the password must be equal to k, any two consecutive symbols in the password must be distinct. Your task is to help Innokentiy and to invent a new password which will satisfy all given conditions.
256 megabytes
import java.util.*; import java.util.StringTokenizer; import java.io.IOException; import java.io.BufferedReader; import java.io.InputStream; import java.io.InputStreamReader; public class sol { public sol() { // TODO Auto-generated constructor stub } public static class Reader { static BufferedReader reader; static StringTokenizer tokenizer; static void init(InputStream input) { reader = new BufferedReader(new InputStreamReader(input)); tokenizer = new StringTokenizer(""); } static String next() throws IOException { while(!tokenizer.hasMoreTokens()) { tokenizer = new StringTokenizer(reader.readLine()); } return tokenizer.nextToken(); } static int nextInt() throws IOException { return Integer.parseInt(next()); } static long nextLong() throws IOException { return Long.parseLong(next()); } } // static int[][] arr2d; // static int n; // static int[] arr; // static String str; static boolean sorted(int[] a) { boolean ans = true; for(int i=1; i<a.length; i++) { if(a[i]<a[i-1]) { ans = false; break; } } return ans; } public static void main(String[] args) throws IOException { // TODO Auto-generated method stub Reader.init(System.in); int n = Reader.nextInt(); int k = Reader.nextInt(); int s = (int)'a'; for(int i=0; i<n; i++) { int t = i%k; char ans = (char)(s+t); System.out.print(ans); } } }
Java
["4 3", "6 6", "5 2"]
1 second
["java", "python", "phphp"]
NoteIn the first test there is one of the appropriate new passwords — java, because its length is equal to 4 and 3 distinct lowercase letters a, j and v are used in it.In the second test there is one of the appropriate new passwords — python, because its length is equal to 6 and it consists of 6 distinct lowercase letters.In the third test there is one of the appropriate new passwords — phphp, because its length is equal to 5 and 2 distinct lowercase letters p and h are used in it.Pay attention the condition that no two identical symbols are consecutive is correct for all appropriate passwords in tests.
Java 11
standard input
[ "implementation", "*special" ]
39f5e934bf293053246bd3faa8061c3b
The first line contains two positive integers n and k (2 ≤ n ≤ 100, 2 ≤ k ≤ min(n, 26)) — the length of the password and the number of distinct symbols in it. Pay attention that a desired new password always exists.
800
Print any password which satisfies all conditions given by Innokentiy.
standard output
PASSED
aafeb96a0a02c7a1b40a80a9ad26b2cc
train_002.jsonl
1489233600
Innokentiy decides to change the password in the social net "Contact!", but he is too lazy to invent a new password by himself. That is why he needs your help. Innokentiy decides that new password should satisfy the following conditions: the length of the password must be equal to n, the password should consist only of lowercase Latin letters, the number of distinct symbols in the password must be equal to k, any two consecutive symbols in the password must be distinct. Your task is to help Innokentiy and to invent a new password which will satisfy all given conditions.
256 megabytes
import java.util.ArrayDeque; import java.util.Arrays; import java.util.Deque; import java.util.Scanner; public class Sheet_A { public static void main(String[] args) { Scanner input = new Scanner(System.in); int n = input.nextInt(); int k = input.nextInt(); String word = ""; for (int i = 0; i < n; i++) word += (char)('a' + (i % k)); System.out.print(word); } } /* int arr[] = new int[n]; for (int i = 0; i < n; i++) arr[i] = input.nextInt(); */ //Arrays.sort(arr); /*for (int i = 0; i < n; i++) System.out.print(arr[i] + " "); */
Java
["4 3", "6 6", "5 2"]
1 second
["java", "python", "phphp"]
NoteIn the first test there is one of the appropriate new passwords — java, because its length is equal to 4 and 3 distinct lowercase letters a, j and v are used in it.In the second test there is one of the appropriate new passwords — python, because its length is equal to 6 and it consists of 6 distinct lowercase letters.In the third test there is one of the appropriate new passwords — phphp, because its length is equal to 5 and 2 distinct lowercase letters p and h are used in it.Pay attention the condition that no two identical symbols are consecutive is correct for all appropriate passwords in tests.
Java 11
standard input
[ "implementation", "*special" ]
39f5e934bf293053246bd3faa8061c3b
The first line contains two positive integers n and k (2 ≤ n ≤ 100, 2 ≤ k ≤ min(n, 26)) — the length of the password and the number of distinct symbols in it. Pay attention that a desired new password always exists.
800
Print any password which satisfies all conditions given by Innokentiy.
standard output
PASSED
dfb7be7ff12baedd53587bab544a460a
train_002.jsonl
1397837400
The R1 company has recently bought a high rise building in the centre of Moscow for its main office. It's time to decorate the new office, and the first thing to do is to write the company's slogan above the main entrance to the building.The slogan of the company consists of n characters, so the decorators hung a large banner, n meters wide and 1 meter high, divided into n equal squares. The first character of the slogan must be in the first square (the leftmost) of the poster, the second character must be in the second square, and so on.Of course, the R1 programmers want to write the slogan on the poster themselves. To do this, they have a large (and a very heavy) ladder which was put exactly opposite the k-th square of the poster. To draw the i-th character of the slogan on the poster, you need to climb the ladder, standing in front of the i-th square of the poster. This action (along with climbing up and down the ladder) takes one hour for a painter. The painter is not allowed to draw characters in the adjacent squares when the ladder is in front of the i-th square because the uncomfortable position of the ladder may make the characters untidy. Besides, the programmers can move the ladder. In one hour, they can move the ladder either a meter to the right or a meter to the left.Drawing characters and moving the ladder is very tiring, so the programmers want to finish the job in as little time as possible. Develop for them an optimal poster painting plan!
256 megabytes
import java.util.*; public class Poster { public static void main(String[]args) { Scanner sc=new Scanner(System.in); int n=sc.nextInt(); int position=sc.nextInt(); String name=sc.next(); if (position>(n/2)) { while(position<n) { System.out.println("RIGHT"); position++; } while(position>0) { System.out.println("PRINT"+" "+name.charAt(position-1)); System.out.println((position!=1)?"LEFT":""); position--; } } else { while(position>1) { System.out.println("LEFT"); position--; } while(position<=n) { System.out.println("PRINT"+" "+name.charAt(position-1)); System.out.println((position!=n)?"RIGHT":""); position++; } } } }
Java
["2 2\nR1", "2 1\nR1", "6 4\nGO?GO!"]
1 second
["PRINT 1\nLEFT\nPRINT R", "PRINT R\nRIGHT\nPRINT 1", "RIGHT\nRIGHT\nPRINT !\nLEFT\nPRINT O\nLEFT\nPRINT G\nLEFT\nPRINT ?\nLEFT\nPRINT O\nLEFT\nPRINT G"]
NoteNote that the ladder cannot be shifted by less than one meter. The ladder can only stand in front of some square of the poster. For example, you cannot shift a ladder by half a meter and position it between two squares. Then go up and paint the first character and the second character.
Java 7
standard input
[ "implementation", "greedy" ]
e3a03f3f01a77a1983121bab4218c39c
The first line contains two integers, n and k (1 ≤ k ≤ n ≤ 100) — the number of characters in the slogan and the initial position of the ladder, correspondingly. The next line contains the slogan as n characters written without spaces. Each character of the slogan is either a large English letter, or digit, or one of the characters: '.', '!', ',', '?'.
900
In t lines, print the actions the programmers need to make. In the i-th line print: "LEFT" (without the quotes), if the i-th action was "move the ladder to the left"; "RIGHT" (without the quotes), if the i-th action was "move the ladder to the right"; "PRINT x" (without the quotes), if the i-th action was to "go up the ladder, paint character x, go down the ladder". The painting time (variable t) must be minimum possible. If there are multiple optimal painting plans, you can print any of them.
standard output
PASSED
0d38109ab9c39cc6f1c67338e5d5eb4f
train_002.jsonl
1397837400
The R1 company has recently bought a high rise building in the centre of Moscow for its main office. It's time to decorate the new office, and the first thing to do is to write the company's slogan above the main entrance to the building.The slogan of the company consists of n characters, so the decorators hung a large banner, n meters wide and 1 meter high, divided into n equal squares. The first character of the slogan must be in the first square (the leftmost) of the poster, the second character must be in the second square, and so on.Of course, the R1 programmers want to write the slogan on the poster themselves. To do this, they have a large (and a very heavy) ladder which was put exactly opposite the k-th square of the poster. To draw the i-th character of the slogan on the poster, you need to climb the ladder, standing in front of the i-th square of the poster. This action (along with climbing up and down the ladder) takes one hour for a painter. The painter is not allowed to draw characters in the adjacent squares when the ladder is in front of the i-th square because the uncomfortable position of the ladder may make the characters untidy. Besides, the programmers can move the ladder. In one hour, they can move the ladder either a meter to the right or a meter to the left.Drawing characters and moving the ladder is very tiring, so the programmers want to finish the job in as little time as possible. Develop for them an optimal poster painting plan!
256 megabytes
import java.util.*; import java.io.*; public class A { static int n,k; static char[] c; public static void main(String[] args) { Scanner in = new Scanner(System.in); StringTokenizer st = new StringTokenizer(in.nextLine()); n = i(st.nextToken()); k = i(st.nextToken()); c = in.nextLine().toCharArray(); if( k <= n/2) { for(; k>1; k--) System.out.println("LEFT"); for(; k<=n; k++) { System.out.println("PRINT " + c[k-1]); if(k<n) System.out.println("RIGHT"); } } else { for(; k < n; k++) System.out.println("RIGHT"); for(; k>=1; k--) { System.out.println("PRINT " + c[k-1]); if(k > 1) System.out.println("LEFT"); } } } static int i(String s) { return Integer.parseInt(s); } }
Java
["2 2\nR1", "2 1\nR1", "6 4\nGO?GO!"]
1 second
["PRINT 1\nLEFT\nPRINT R", "PRINT R\nRIGHT\nPRINT 1", "RIGHT\nRIGHT\nPRINT !\nLEFT\nPRINT O\nLEFT\nPRINT G\nLEFT\nPRINT ?\nLEFT\nPRINT O\nLEFT\nPRINT G"]
NoteNote that the ladder cannot be shifted by less than one meter. The ladder can only stand in front of some square of the poster. For example, you cannot shift a ladder by half a meter and position it between two squares. Then go up and paint the first character and the second character.
Java 7
standard input
[ "implementation", "greedy" ]
e3a03f3f01a77a1983121bab4218c39c
The first line contains two integers, n and k (1 ≤ k ≤ n ≤ 100) — the number of characters in the slogan and the initial position of the ladder, correspondingly. The next line contains the slogan as n characters written without spaces. Each character of the slogan is either a large English letter, or digit, or one of the characters: '.', '!', ',', '?'.
900
In t lines, print the actions the programmers need to make. In the i-th line print: "LEFT" (without the quotes), if the i-th action was "move the ladder to the left"; "RIGHT" (without the quotes), if the i-th action was "move the ladder to the right"; "PRINT x" (without the quotes), if the i-th action was to "go up the ladder, paint character x, go down the ladder". The painting time (variable t) must be minimum possible. If there are multiple optimal painting plans, you can print any of them.
standard output
PASSED
4c8cd338c7eed2dd7481649798ab90f2
train_002.jsonl
1397837400
The R1 company has recently bought a high rise building in the centre of Moscow for its main office. It's time to decorate the new office, and the first thing to do is to write the company's slogan above the main entrance to the building.The slogan of the company consists of n characters, so the decorators hung a large banner, n meters wide and 1 meter high, divided into n equal squares. The first character of the slogan must be in the first square (the leftmost) of the poster, the second character must be in the second square, and so on.Of course, the R1 programmers want to write the slogan on the poster themselves. To do this, they have a large (and a very heavy) ladder which was put exactly opposite the k-th square of the poster. To draw the i-th character of the slogan on the poster, you need to climb the ladder, standing in front of the i-th square of the poster. This action (along with climbing up and down the ladder) takes one hour for a painter. The painter is not allowed to draw characters in the adjacent squares when the ladder is in front of the i-th square because the uncomfortable position of the ladder may make the characters untidy. Besides, the programmers can move the ladder. In one hour, they can move the ladder either a meter to the right or a meter to the left.Drawing characters and moving the ladder is very tiring, so the programmers want to finish the job in as little time as possible. Develop for them an optimal poster painting plan!
256 megabytes
import java.util.Scanner; public class A { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int k = sc.nextInt(); String s = sc.next(); int pos = k-1; while(pos!=0 && pos!=n-1){ if(pos <= (n-1)/2){ System.out.println("LEFT"); pos--; }else{ System.out.println("RIGHT"); pos++; } } int way; if(pos==0)way=1; else way=-1; int pos2 = pos; for(int i=0; i<n; i++){ if(way==1){ System.out.println("PRINT "+s.charAt(pos2)); if(i!=n-1)System.out.println("RIGHT"); pos2++; }else{ System.out.println("PRINT "+s.charAt(pos2)); if(i!=n-1)System.out.println("LEFT"); pos2--; } } sc.close(); } }
Java
["2 2\nR1", "2 1\nR1", "6 4\nGO?GO!"]
1 second
["PRINT 1\nLEFT\nPRINT R", "PRINT R\nRIGHT\nPRINT 1", "RIGHT\nRIGHT\nPRINT !\nLEFT\nPRINT O\nLEFT\nPRINT G\nLEFT\nPRINT ?\nLEFT\nPRINT O\nLEFT\nPRINT G"]
NoteNote that the ladder cannot be shifted by less than one meter. The ladder can only stand in front of some square of the poster. For example, you cannot shift a ladder by half a meter and position it between two squares. Then go up and paint the first character and the second character.
Java 7
standard input
[ "implementation", "greedy" ]
e3a03f3f01a77a1983121bab4218c39c
The first line contains two integers, n and k (1 ≤ k ≤ n ≤ 100) — the number of characters in the slogan and the initial position of the ladder, correspondingly. The next line contains the slogan as n characters written without spaces. Each character of the slogan is either a large English letter, or digit, or one of the characters: '.', '!', ',', '?'.
900
In t lines, print the actions the programmers need to make. In the i-th line print: "LEFT" (without the quotes), if the i-th action was "move the ladder to the left"; "RIGHT" (without the quotes), if the i-th action was "move the ladder to the right"; "PRINT x" (without the quotes), if the i-th action was to "go up the ladder, paint character x, go down the ladder". The painting time (variable t) must be minimum possible. If there are multiple optimal painting plans, you can print any of them.
standard output
PASSED
c9fee1ce990a9d41d753da25b62e0903
train_002.jsonl
1397837400
The R1 company has recently bought a high rise building in the centre of Moscow for its main office. It's time to decorate the new office, and the first thing to do is to write the company's slogan above the main entrance to the building.The slogan of the company consists of n characters, so the decorators hung a large banner, n meters wide and 1 meter high, divided into n equal squares. The first character of the slogan must be in the first square (the leftmost) of the poster, the second character must be in the second square, and so on.Of course, the R1 programmers want to write the slogan on the poster themselves. To do this, they have a large (and a very heavy) ladder which was put exactly opposite the k-th square of the poster. To draw the i-th character of the slogan on the poster, you need to climb the ladder, standing in front of the i-th square of the poster. This action (along with climbing up and down the ladder) takes one hour for a painter. The painter is not allowed to draw characters in the adjacent squares when the ladder is in front of the i-th square because the uncomfortable position of the ladder may make the characters untidy. Besides, the programmers can move the ladder. In one hour, they can move the ladder either a meter to the right or a meter to the left.Drawing characters and moving the ladder is very tiring, so the programmers want to finish the job in as little time as possible. Develop for them an optimal poster painting plan!
256 megabytes
import java.util.Scanner; public class CoderStrike1A { /** * @param args */ public static void main(String[] args) { Scanner sc=new Scanner(System.in); int n=sc.nextInt(); int index=sc.nextInt(); String s=sc.next(); boolean goToRight=false; StringBuilder x=new StringBuilder(); if(index-1>s.length()-index){ for(int i=0;i<s.length()-index;i++){ x.append("RIGHT"); x.append("\n"); } index=s.length(); } else { for(int i=0;i<index-1;i++){ x.append("LEFT"); x.append("\n"); } goToRight=true; index=1; } if(index==1){ for(int i=0;i<s.length();i++){ x.append("PRINT "+s.charAt(i)); x.append("\n"); if(i!=s.length()-1) x.append("RIGHT"); x.append("\n"); } } else { for(int i=s.length()-1;i>=0;i--){ x.append("PRINT "+s.charAt(i)); x.append("\n"); if(i!=0) x.append("LEFT"); x.append("\n"); } } System.out.println(x); } }
Java
["2 2\nR1", "2 1\nR1", "6 4\nGO?GO!"]
1 second
["PRINT 1\nLEFT\nPRINT R", "PRINT R\nRIGHT\nPRINT 1", "RIGHT\nRIGHT\nPRINT !\nLEFT\nPRINT O\nLEFT\nPRINT G\nLEFT\nPRINT ?\nLEFT\nPRINT O\nLEFT\nPRINT G"]
NoteNote that the ladder cannot be shifted by less than one meter. The ladder can only stand in front of some square of the poster. For example, you cannot shift a ladder by half a meter and position it between two squares. Then go up and paint the first character and the second character.
Java 7
standard input
[ "implementation", "greedy" ]
e3a03f3f01a77a1983121bab4218c39c
The first line contains two integers, n and k (1 ≤ k ≤ n ≤ 100) — the number of characters in the slogan and the initial position of the ladder, correspondingly. The next line contains the slogan as n characters written without spaces. Each character of the slogan is either a large English letter, or digit, or one of the characters: '.', '!', ',', '?'.
900
In t lines, print the actions the programmers need to make. In the i-th line print: "LEFT" (without the quotes), if the i-th action was "move the ladder to the left"; "RIGHT" (without the quotes), if the i-th action was "move the ladder to the right"; "PRINT x" (without the quotes), if the i-th action was to "go up the ladder, paint character x, go down the ladder". The painting time (variable t) must be minimum possible. If there are multiple optimal painting plans, you can print any of them.
standard output
PASSED
e2afbae426089fb1aa0229884b53b99d
train_002.jsonl
1397837400
The R1 company has recently bought a high rise building in the centre of Moscow for its main office. It's time to decorate the new office, and the first thing to do is to write the company's slogan above the main entrance to the building.The slogan of the company consists of n characters, so the decorators hung a large banner, n meters wide and 1 meter high, divided into n equal squares. The first character of the slogan must be in the first square (the leftmost) of the poster, the second character must be in the second square, and so on.Of course, the R1 programmers want to write the slogan on the poster themselves. To do this, they have a large (and a very heavy) ladder which was put exactly opposite the k-th square of the poster. To draw the i-th character of the slogan on the poster, you need to climb the ladder, standing in front of the i-th square of the poster. This action (along with climbing up and down the ladder) takes one hour for a painter. The painter is not allowed to draw characters in the adjacent squares when the ladder is in front of the i-th square because the uncomfortable position of the ladder may make the characters untidy. Besides, the programmers can move the ladder. In one hour, they can move the ladder either a meter to the right or a meter to the left.Drawing characters and moving the ladder is very tiring, so the programmers want to finish the job in as little time as possible. Develop for them an optimal poster painting plan!
256 megabytes
import java.util.*; public class first { public static void main(String[] args) throws Exception { Scanner in = new Scanner(System.in); String str = in.nextLine(); int n = Integer.parseInt(str.substring(0, str.indexOf(" "))); int k = Integer.parseInt(str.substring(str.indexOf(" ") + 1)); char[] arr = in.nextLine().toCharArray(); if(k <= n/2) { for(int i = 0; i < k - 1; i++) { System.out.println("LEFT"); } for(int i = 0; i < arr.length - 1; i++) { System.out.println("PRINT " + arr[i]); System.out.println("RIGHT"); } System.out.println("PRINT " + arr[arr.length - 1]); } else { for(int i = k; i < n; i++) { System.out.println("RIGHT"); } for(int i = arr.length - 1; i > 0; i--) { System.out.println("PRINT " + arr[i]); System.out.println("LEFT"); } System.out.println("PRINT " + arr[0]); } } }
Java
["2 2\nR1", "2 1\nR1", "6 4\nGO?GO!"]
1 second
["PRINT 1\nLEFT\nPRINT R", "PRINT R\nRIGHT\nPRINT 1", "RIGHT\nRIGHT\nPRINT !\nLEFT\nPRINT O\nLEFT\nPRINT G\nLEFT\nPRINT ?\nLEFT\nPRINT O\nLEFT\nPRINT G"]
NoteNote that the ladder cannot be shifted by less than one meter. The ladder can only stand in front of some square of the poster. For example, you cannot shift a ladder by half a meter and position it between two squares. Then go up and paint the first character and the second character.
Java 7
standard input
[ "implementation", "greedy" ]
e3a03f3f01a77a1983121bab4218c39c
The first line contains two integers, n and k (1 ≤ k ≤ n ≤ 100) — the number of characters in the slogan and the initial position of the ladder, correspondingly. The next line contains the slogan as n characters written without spaces. Each character of the slogan is either a large English letter, or digit, or one of the characters: '.', '!', ',', '?'.
900
In t lines, print the actions the programmers need to make. In the i-th line print: "LEFT" (without the quotes), if the i-th action was "move the ladder to the left"; "RIGHT" (without the quotes), if the i-th action was "move the ladder to the right"; "PRINT x" (without the quotes), if the i-th action was to "go up the ladder, paint character x, go down the ladder". The painting time (variable t) must be minimum possible. If there are multiple optimal painting plans, you can print any of them.
standard output
PASSED
9b895a7ffe283807833dcfad4f0e8e20
train_002.jsonl
1397837400
The R1 company has recently bought a high rise building in the centre of Moscow for its main office. It's time to decorate the new office, and the first thing to do is to write the company's slogan above the main entrance to the building.The slogan of the company consists of n characters, so the decorators hung a large banner, n meters wide and 1 meter high, divided into n equal squares. The first character of the slogan must be in the first square (the leftmost) of the poster, the second character must be in the second square, and so on.Of course, the R1 programmers want to write the slogan on the poster themselves. To do this, they have a large (and a very heavy) ladder which was put exactly opposite the k-th square of the poster. To draw the i-th character of the slogan on the poster, you need to climb the ladder, standing in front of the i-th square of the poster. This action (along with climbing up and down the ladder) takes one hour for a painter. The painter is not allowed to draw characters in the adjacent squares when the ladder is in front of the i-th square because the uncomfortable position of the ladder may make the characters untidy. Besides, the programmers can move the ladder. In one hour, they can move the ladder either a meter to the right or a meter to the left.Drawing characters and moving the ladder is very tiring, so the programmers want to finish the job in as little time as possible. Develop for them an optimal poster painting plan!
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.util.StringTokenizer; public class A { static BufferedReader br; static StringTokenizer st; static PrintWriter pw; /* Designed by Shoh */ public static void main(String[] args) throws IOException { br = new BufferedReader(new InputStreamReader(System.in)); pw = new PrintWriter(new OutputStreamWriter(System.out)); int n = nexInt(), k = nexInt(); String s = next(); if (2 * k <= n) { for (int i = 1; i <= k - 1; i++) System.out.println("LEFT"); for (int i = 0; i < s.length(); i++) { System.out.println("PRINT " + s.charAt(i)); if (i != s.length() - 1) System.out.println("RIGHT"); } } else { for (int i = 1; i <= n - k; i++) System.out.println("RIGHT"); for (int i = s.length()-1 ; i >= 0; i--) { System.out.println("PRINT " + s.charAt(i)); if(i!=0) System.out.println("LEFT"); } } pw.close(); } private static int nexInt() throws IOException { return Integer.parseInt(next()); } private static double nexDouble() throws IOException { return Double.parseDouble(next()); } private static long nexLong() throws IOException { return Long.parseLong(next()); } private static String next() throws IOException { while (st == null || !st.hasMoreTokens()) st = new StringTokenizer(br.readLine()); return st.nextToken(); } }
Java
["2 2\nR1", "2 1\nR1", "6 4\nGO?GO!"]
1 second
["PRINT 1\nLEFT\nPRINT R", "PRINT R\nRIGHT\nPRINT 1", "RIGHT\nRIGHT\nPRINT !\nLEFT\nPRINT O\nLEFT\nPRINT G\nLEFT\nPRINT ?\nLEFT\nPRINT O\nLEFT\nPRINT G"]
NoteNote that the ladder cannot be shifted by less than one meter. The ladder can only stand in front of some square of the poster. For example, you cannot shift a ladder by half a meter and position it between two squares. Then go up and paint the first character and the second character.
Java 7
standard input
[ "implementation", "greedy" ]
e3a03f3f01a77a1983121bab4218c39c
The first line contains two integers, n and k (1 ≤ k ≤ n ≤ 100) — the number of characters in the slogan and the initial position of the ladder, correspondingly. The next line contains the slogan as n characters written without spaces. Each character of the slogan is either a large English letter, or digit, or one of the characters: '.', '!', ',', '?'.
900
In t lines, print the actions the programmers need to make. In the i-th line print: "LEFT" (without the quotes), if the i-th action was "move the ladder to the left"; "RIGHT" (without the quotes), if the i-th action was "move the ladder to the right"; "PRINT x" (without the quotes), if the i-th action was to "go up the ladder, paint character x, go down the ladder". The painting time (variable t) must be minimum possible. If there are multiple optimal painting plans, you can print any of them.
standard output
PASSED
93db58d16e37a8cdd197becb26c70b04
train_002.jsonl
1397837400
The R1 company has recently bought a high rise building in the centre of Moscow for its main office. It's time to decorate the new office, and the first thing to do is to write the company's slogan above the main entrance to the building.The slogan of the company consists of n characters, so the decorators hung a large banner, n meters wide and 1 meter high, divided into n equal squares. The first character of the slogan must be in the first square (the leftmost) of the poster, the second character must be in the second square, and so on.Of course, the R1 programmers want to write the slogan on the poster themselves. To do this, they have a large (and a very heavy) ladder which was put exactly opposite the k-th square of the poster. To draw the i-th character of the slogan on the poster, you need to climb the ladder, standing in front of the i-th square of the poster. This action (along with climbing up and down the ladder) takes one hour for a painter. The painter is not allowed to draw characters in the adjacent squares when the ladder is in front of the i-th square because the uncomfortable position of the ladder may make the characters untidy. Besides, the programmers can move the ladder. In one hour, they can move the ladder either a meter to the right or a meter to the left.Drawing characters and moving the ladder is very tiring, so the programmers want to finish the job in as little time as possible. Develop for them an optimal poster painting plan!
256 megabytes
import java.io.BufferedReader; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.math.BigInteger; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.HashSet; import java.util.LinkedList; import java.util.PriorityQueue; import java.util.Queue; import java.util.Scanner; import java.util.Stack; import java.util.concurrent.PriorityBlockingQueue; import javax.swing.ComboBoxEditor; public class aa { public static class node { int money; int moniter; int numOfProblem; node(int d, int t, int n) { money = d; moniter = t; numOfProblem = n; } } public static class point implements Comparable<point> { int mask; long val; point(int mask, long val) { this.mask = mask; this.val = val; } @Override public int compareTo(point o) { if (o.val < val) return 1; else return -1; } } public static void solve() { } public static void main(String[] args) throws IOException { BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out)); StringBuilder q = new StringBuilder(); StringBuilder e = new StringBuilder(); String y[] = in.readLine().split(" "); int n = Integer.parseInt(y[0]); int k = Integer.parseInt(y[1]) - 1; int t = k; String a = in.readLine(); boolean ch[] = new boolean[n]; int c = 0; boolean flag = true; int count = 0; while (c < n) { if (!ch[k]) { q.append("PRINT " + a.charAt(k) + "\n"); ch[k] = true; c++; count++; } if (k == n - 1) { flag = false; } if (c == n) break; if (flag) { k++; q.append("RIGHT\n"); count++; } else { k--; q.append("LEFT\n"); count++; } } // ....................... c = 0; k = t; // System.out.println(k); flag = true; ch = new boolean[n]; int count2 = 0; while (c < n) { if (!ch[k]) { e.append("PRINT " + a.charAt(k) + "\n"); ch[k] = true; count2++; c++; } if (k == 0) { flag = false; } if (c == n) break; if (flag) { k--; e.append("LEFT\n"); count2++; } else { k++; e.append("RIGHT\n"); count2++; } } if(count<count2) System.out.print(q); else System.out.print(e); //System.out.print((count<count2?q:e)); //out.print(q); out.close(); } }
Java
["2 2\nR1", "2 1\nR1", "6 4\nGO?GO!"]
1 second
["PRINT 1\nLEFT\nPRINT R", "PRINT R\nRIGHT\nPRINT 1", "RIGHT\nRIGHT\nPRINT !\nLEFT\nPRINT O\nLEFT\nPRINT G\nLEFT\nPRINT ?\nLEFT\nPRINT O\nLEFT\nPRINT G"]
NoteNote that the ladder cannot be shifted by less than one meter. The ladder can only stand in front of some square of the poster. For example, you cannot shift a ladder by half a meter and position it between two squares. Then go up and paint the first character and the second character.
Java 7
standard input
[ "implementation", "greedy" ]
e3a03f3f01a77a1983121bab4218c39c
The first line contains two integers, n and k (1 ≤ k ≤ n ≤ 100) — the number of characters in the slogan and the initial position of the ladder, correspondingly. The next line contains the slogan as n characters written without spaces. Each character of the slogan is either a large English letter, or digit, or one of the characters: '.', '!', ',', '?'.
900
In t lines, print the actions the programmers need to make. In the i-th line print: "LEFT" (without the quotes), if the i-th action was "move the ladder to the left"; "RIGHT" (without the quotes), if the i-th action was "move the ladder to the right"; "PRINT x" (without the quotes), if the i-th action was to "go up the ladder, paint character x, go down the ladder". The painting time (variable t) must be minimum possible. If there are multiple optimal painting plans, you can print any of them.
standard output
PASSED
6a04fa1c1de83df7c805555b3fb46415
train_002.jsonl
1397837400
The R1 company has recently bought a high rise building in the centre of Moscow for its main office. It's time to decorate the new office, and the first thing to do is to write the company's slogan above the main entrance to the building.The slogan of the company consists of n characters, so the decorators hung a large banner, n meters wide and 1 meter high, divided into n equal squares. The first character of the slogan must be in the first square (the leftmost) of the poster, the second character must be in the second square, and so on.Of course, the R1 programmers want to write the slogan on the poster themselves. To do this, they have a large (and a very heavy) ladder which was put exactly opposite the k-th square of the poster. To draw the i-th character of the slogan on the poster, you need to climb the ladder, standing in front of the i-th square of the poster. This action (along with climbing up and down the ladder) takes one hour for a painter. The painter is not allowed to draw characters in the adjacent squares when the ladder is in front of the i-th square because the uncomfortable position of the ladder may make the characters untidy. Besides, the programmers can move the ladder. In one hour, they can move the ladder either a meter to the right or a meter to the left.Drawing characters and moving the ladder is very tiring, so the programmers want to finish the job in as little time as possible. Develop for them an optimal poster painting plan!
256 megabytes
import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.HashMap; import java.util.InputMismatchException; public class A { public static void main(String[] args) throws Exception{ FasterScanner sc = new FasterScanner(); PrintWriter out = new PrintWriter(System.out); int N = sc.nextInt(); int K = sc.nextInt(); String in =sc.next(); //left int pos = K; if(N-K>=K){ while(pos!=1){ out.println("LEFT"); pos--; } for(int a=1;a<=N;a++){ out.println("PRINT "+(char)in.charAt(a-1)); if(a!=N) out.println("RIGHT"); } } else{ while(pos!=N){ out.println("RIGHT"); pos++; } for(int a=N;a>=1;a--){ out.println("PRINT "+(char)in.charAt(a-1)); if(a!=1) out.println("LEFT"); } } out.close(); } static class FasterScanner{ private InputStream stream; private byte[] buf = new byte[1024]; private int curChar; private int numChars; public FasterScanner() throws FileNotFoundException{ stream = System.in; // stream = new FileInputStream(new File("triangles.in")); } int read(){ if(numChars==-1) throw new InputMismatchException(); if(curChar>=numChars){ curChar = 0; try{ numChars = stream.read(buf); } catch (IOException e){ throw new InputMismatchException(); } if(numChars <= 0) return -1; } return buf[curChar++]; } boolean isSpaceChar(int c){ return c==' '||c=='\n'||c=='\r'||c=='\t'||c==-1; } boolean isEndline(int c){ return c=='\n'||c=='\r'||c==-1; } int nextInt(){ return Integer.parseInt(next()); } long nextLong(){ return Long.parseLong(next()); } double nextDouble(){ return Double.parseDouble(next()); } String next(){ int c = read(); while(isSpaceChar(c)) c=read(); StringBuilder res = new StringBuilder(); do{ res.appendCodePoint(c); c=read(); } while(!isSpaceChar(c)); return res.toString(); } String nextLine(){ int c = read(); while(isEndline(c)) c=read(); StringBuilder res = new StringBuilder(); do{ res.appendCodePoint(c); c = read(); }while(!isEndline(c)); return res.toString(); } } }
Java
["2 2\nR1", "2 1\nR1", "6 4\nGO?GO!"]
1 second
["PRINT 1\nLEFT\nPRINT R", "PRINT R\nRIGHT\nPRINT 1", "RIGHT\nRIGHT\nPRINT !\nLEFT\nPRINT O\nLEFT\nPRINT G\nLEFT\nPRINT ?\nLEFT\nPRINT O\nLEFT\nPRINT G"]
NoteNote that the ladder cannot be shifted by less than one meter. The ladder can only stand in front of some square of the poster. For example, you cannot shift a ladder by half a meter and position it between two squares. Then go up and paint the first character and the second character.
Java 7
standard input
[ "implementation", "greedy" ]
e3a03f3f01a77a1983121bab4218c39c
The first line contains two integers, n and k (1 ≤ k ≤ n ≤ 100) — the number of characters in the slogan and the initial position of the ladder, correspondingly. The next line contains the slogan as n characters written without spaces. Each character of the slogan is either a large English letter, or digit, or one of the characters: '.', '!', ',', '?'.
900
In t lines, print the actions the programmers need to make. In the i-th line print: "LEFT" (without the quotes), if the i-th action was "move the ladder to the left"; "RIGHT" (without the quotes), if the i-th action was "move the ladder to the right"; "PRINT x" (without the quotes), if the i-th action was to "go up the ladder, paint character x, go down the ladder". The painting time (variable t) must be minimum possible. If there are multiple optimal painting plans, you can print any of them.
standard output
PASSED
f3904bef262e1ceabf177a7951ed1c61
train_002.jsonl
1397837400
The R1 company has recently bought a high rise building in the centre of Moscow for its main office. It's time to decorate the new office, and the first thing to do is to write the company's slogan above the main entrance to the building.The slogan of the company consists of n characters, so the decorators hung a large banner, n meters wide and 1 meter high, divided into n equal squares. The first character of the slogan must be in the first square (the leftmost) of the poster, the second character must be in the second square, and so on.Of course, the R1 programmers want to write the slogan on the poster themselves. To do this, they have a large (and a very heavy) ladder which was put exactly opposite the k-th square of the poster. To draw the i-th character of the slogan on the poster, you need to climb the ladder, standing in front of the i-th square of the poster. This action (along with climbing up and down the ladder) takes one hour for a painter. The painter is not allowed to draw characters in the adjacent squares when the ladder is in front of the i-th square because the uncomfortable position of the ladder may make the characters untidy. Besides, the programmers can move the ladder. In one hour, they can move the ladder either a meter to the right or a meter to the left.Drawing characters and moving the ladder is very tiring, so the programmers want to finish the job in as little time as possible. Develop for them an optimal poster painting plan!
256 megabytes
import java.io.IOException; import java.io.OutputStreamWriter; import java.io.BufferedWriter; import java.util.InputMismatchException; import java.io.OutputStream; import java.io.PrintWriter; import java.util.NoSuchElementException; import java.io.Writer; import java.math.BigInteger; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the top * @author Nguyen Trung Hieu - vuondenthanhcong11@gmail.com */ public class Main { public static void main(String[] args) { InputStream inputStream = System.in; OutputStream outputStream = System.out; InputReader in = new InputReader(inputStream); OutputWriter out = new OutputWriter(outputStream); TaskA solver = new TaskA(); solver.solve(1, in, out); out.close(); } } class TaskA { public void solve(int testNumber, InputReader in, OutputWriter out) { int count = in.readInt(); int idx = in.readInt() - 1; char[] words = in.readString().toCharArray(); if (idx >= (count - idx - 1)) { for (int i = 0; i < count - idx - 1; i++) out.printLine("RIGHT"); for (int i = count - 1; i >= 0; i--) { out.printLine("PRINT " + words[i]); if (i > 0) out.printLine("LEFT"); } } else { for (int i = 0; i < idx; i++) out.printLine("LEFT"); for (int i = 0; i < count; i++) { if (i > 0) out.printLine("RIGHT"); out.printLine("PRINT " + words[i]); } } } } class InputReader { private InputStream stream; private byte[] buf = new byte[1024]; private int curChar; private int numChars; private SpaceCharFilter filter; public InputReader(InputStream stream) { this.stream = stream; } public int read() { if (numChars == -1) throw new InputMismatchException(); if (curChar >= numChars) { curChar = 0; try { numChars = stream.read(buf); } catch (IOException e) { throw new InputMismatchException(); } if (numChars <= 0) return -1; } return buf[curChar++]; } public int readInt() { int c = read(); while (isSpaceChar(c)) c = read(); int sgn = 1; if (c == '-') { sgn = -1; c = read(); } int res = 0; do { if (c < '0' || c > '9') throw new InputMismatchException(); res *= 10; res += c - '0'; c = read(); } while (!isSpaceChar(c)); return res * sgn; } public boolean isSpaceChar(int c) { if (filter != null) return filter.isSpaceChar(c); return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1; } public String readString() { int c = read(); while (isSpaceChar(c)) c = read(); StringBuffer res = new StringBuffer(); do { res.appendCodePoint(c); c = read(); } while (!isSpaceChar(c)); return res.toString(); } public interface SpaceCharFilter { public boolean isSpaceChar(int ch); } } class OutputWriter { private final PrintWriter writer; public OutputWriter(OutputStream outputStream) { writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream))); } public OutputWriter(Writer writer) { this.writer = new PrintWriter(writer); } public void print(Object...objects) { for (int i = 0; i < objects.length; i++) { if (i != 0) writer.print(' '); writer.print(objects[i]); } } public void printLine(Object...objects) { print(objects); writer.println(); } public void close() { writer.close(); } }
Java
["2 2\nR1", "2 1\nR1", "6 4\nGO?GO!"]
1 second
["PRINT 1\nLEFT\nPRINT R", "PRINT R\nRIGHT\nPRINT 1", "RIGHT\nRIGHT\nPRINT !\nLEFT\nPRINT O\nLEFT\nPRINT G\nLEFT\nPRINT ?\nLEFT\nPRINT O\nLEFT\nPRINT G"]
NoteNote that the ladder cannot be shifted by less than one meter. The ladder can only stand in front of some square of the poster. For example, you cannot shift a ladder by half a meter and position it between two squares. Then go up and paint the first character and the second character.
Java 7
standard input
[ "implementation", "greedy" ]
e3a03f3f01a77a1983121bab4218c39c
The first line contains two integers, n and k (1 ≤ k ≤ n ≤ 100) — the number of characters in the slogan and the initial position of the ladder, correspondingly. The next line contains the slogan as n characters written without spaces. Each character of the slogan is either a large English letter, or digit, or one of the characters: '.', '!', ',', '?'.
900
In t lines, print the actions the programmers need to make. In the i-th line print: "LEFT" (without the quotes), if the i-th action was "move the ladder to the left"; "RIGHT" (without the quotes), if the i-th action was "move the ladder to the right"; "PRINT x" (without the quotes), if the i-th action was to "go up the ladder, paint character x, go down the ladder". The painting time (variable t) must be minimum possible. If there are multiple optimal painting plans, you can print any of them.
standard output
PASSED
1aa033639b9d4d172cc10b7213df81d6
train_002.jsonl
1397837400
The R1 company has recently bought a high rise building in the centre of Moscow for its main office. It's time to decorate the new office, and the first thing to do is to write the company's slogan above the main entrance to the building.The slogan of the company consists of n characters, so the decorators hung a large banner, n meters wide and 1 meter high, divided into n equal squares. The first character of the slogan must be in the first square (the leftmost) of the poster, the second character must be in the second square, and so on.Of course, the R1 programmers want to write the slogan on the poster themselves. To do this, they have a large (and a very heavy) ladder which was put exactly opposite the k-th square of the poster. To draw the i-th character of the slogan on the poster, you need to climb the ladder, standing in front of the i-th square of the poster. This action (along with climbing up and down the ladder) takes one hour for a painter. The painter is not allowed to draw characters in the adjacent squares when the ladder is in front of the i-th square because the uncomfortable position of the ladder may make the characters untidy. Besides, the programmers can move the ladder. In one hour, they can move the ladder either a meter to the right or a meter to the left.Drawing characters and moving the ladder is very tiring, so the programmers want to finish the job in as little time as possible. Develop for them an optimal poster painting plan!
256 megabytes
import java.io.IOException; import java.io.OutputStreamWriter; import java.io.BufferedWriter; import java.util.InputMismatchException; import java.io.OutputStream; import java.io.PrintWriter; import java.io.Writer; import java.math.BigInteger; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the top * @author Ziklon */ public class Main { public static void main(String[] args) { InputStream inputStream = System.in; OutputStream outputStream = System.out; InputReader in = new InputReader(inputStream); OutputWriter out = new OutputWriter(outputStream); TaskA solver = new TaskA(); solver.solve(1, in, out); out.close(); } } class TaskA { public void solve(int testNumber, InputReader in, OutputWriter out) { int n = in.nextInt(), k = in.nextInt(); String slogan = in.nextString(); boolean rev = false; if (k > n - k) { for (int i = k; i < n; i++) out.println("RIGHT"); k = n; rev = true; } else { for (int i = k; i > 1; i--) out.println("LEFT"); k = 1; } for (int i = 0; i < n; i++) { out.println("PRINT " + slogan.charAt(k - 1)); if (rev) { k = k - 1; } else { k = k + 1; } if (i + 1 < n) { out.println(rev ? "LEFT" : "RIGHT"); } } } } class InputReader { InputStream stream; byte[] buf = new byte[1024]; int curChar, numChars; public InputReader(InputStream stream) { this.stream = stream; } private int read() { if (numChars == -1) throw new InputMismatchException(); if (curChar >= numChars) { curChar = 0; try { numChars = stream.read(buf); } catch (IOException e) { throw new InputMismatchException(); } if (numChars <= 0) return -1; } return buf[curChar++]; } public int nextInt() { int c = read(); while (isSpaceChar(c)) c = read(); int sgn = 1; if (c == '-') { sgn = -1; c = read(); } int res = 0; do { if (c < '0' || c > '9') throw new InputMismatchException(); res *= 10; res += c - '0'; c = read(); } while (!isSpaceChar(c)); return res * sgn; } public String nextString() { int c = read(); while (isSpaceChar(c)) c = read(); StringBuffer res = new StringBuffer(); do { res.appendCodePoint(c); c = read(); } while (!isSpaceChar(c)); return res.toString(); } private boolean isSpaceChar(int c) { return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1; } } class OutputWriter { private final PrintWriter writer; public OutputWriter(OutputStream outputStream) { writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream))); } public OutputWriter(Writer writer) { this.writer = new PrintWriter(writer); } public void print(Object... objects) { for (int i = 0; i < objects.length; i++) { if (i != 0) writer.print(' '); writer.print(objects[i]); } } public void println(Object... objects) { print(objects); writer.println(); } public void close() { writer.close(); } }
Java
["2 2\nR1", "2 1\nR1", "6 4\nGO?GO!"]
1 second
["PRINT 1\nLEFT\nPRINT R", "PRINT R\nRIGHT\nPRINT 1", "RIGHT\nRIGHT\nPRINT !\nLEFT\nPRINT O\nLEFT\nPRINT G\nLEFT\nPRINT ?\nLEFT\nPRINT O\nLEFT\nPRINT G"]
NoteNote that the ladder cannot be shifted by less than one meter. The ladder can only stand in front of some square of the poster. For example, you cannot shift a ladder by half a meter and position it between two squares. Then go up and paint the first character and the second character.
Java 7
standard input
[ "implementation", "greedy" ]
e3a03f3f01a77a1983121bab4218c39c
The first line contains two integers, n and k (1 ≤ k ≤ n ≤ 100) — the number of characters in the slogan and the initial position of the ladder, correspondingly. The next line contains the slogan as n characters written without spaces. Each character of the slogan is either a large English letter, or digit, or one of the characters: '.', '!', ',', '?'.
900
In t lines, print the actions the programmers need to make. In the i-th line print: "LEFT" (without the quotes), if the i-th action was "move the ladder to the left"; "RIGHT" (without the quotes), if the i-th action was "move the ladder to the right"; "PRINT x" (without the quotes), if the i-th action was to "go up the ladder, paint character x, go down the ladder". The painting time (variable t) must be minimum possible. If there are multiple optimal painting plans, you can print any of them.
standard output
PASSED
689941e980467689098bc07dd8d68751
train_002.jsonl
1397837400
The R1 company has recently bought a high rise building in the centre of Moscow for its main office. It's time to decorate the new office, and the first thing to do is to write the company's slogan above the main entrance to the building.The slogan of the company consists of n characters, so the decorators hung a large banner, n meters wide and 1 meter high, divided into n equal squares. The first character of the slogan must be in the first square (the leftmost) of the poster, the second character must be in the second square, and so on.Of course, the R1 programmers want to write the slogan on the poster themselves. To do this, they have a large (and a very heavy) ladder which was put exactly opposite the k-th square of the poster. To draw the i-th character of the slogan on the poster, you need to climb the ladder, standing in front of the i-th square of the poster. This action (along with climbing up and down the ladder) takes one hour for a painter. The painter is not allowed to draw characters in the adjacent squares when the ladder is in front of the i-th square because the uncomfortable position of the ladder may make the characters untidy. Besides, the programmers can move the ladder. In one hour, they can move the ladder either a meter to the right or a meter to the left.Drawing characters and moving the ladder is very tiring, so the programmers want to finish the job in as little time as possible. Develop for them an optimal poster painting plan!
256 megabytes
import java.util.*; public class aa { public static void main(String[] args) { Scanner input = new Scanner(System.in); int n = input.nextInt(), k = input.nextInt()-1; int copy = k; String s = input.next(); if(k < n/2) { while(k > 0) { System.out.println("PRINT " + s.charAt(k)); System.out.println("LEFT"); k--; } System.out.println("PRINT " + s.charAt(k)); while(k <= copy && k < n-1) { System.out.println("RIGHT"); k++; } while(k<n) { if(k>copy) System.out.println("PRINT " + s.charAt(k)); if (k<n-1)System.out.println("RIGHT"); k++; } } else { while(k < n-1) { System.out.println("PRINT " + s.charAt(k)); System.out.println("RIGHT"); k++; } System.out.println("PRINT " + s.charAt(n-1)); while(k >= copy && k > 0) { System.out.println("LEFT"); k--; } while(k>=0) { if(k < copy) System.out.println("PRINT " + s.charAt(k)); if (k > 0)System.out.println("LEFT"); k--; } } } }
Java
["2 2\nR1", "2 1\nR1", "6 4\nGO?GO!"]
1 second
["PRINT 1\nLEFT\nPRINT R", "PRINT R\nRIGHT\nPRINT 1", "RIGHT\nRIGHT\nPRINT !\nLEFT\nPRINT O\nLEFT\nPRINT G\nLEFT\nPRINT ?\nLEFT\nPRINT O\nLEFT\nPRINT G"]
NoteNote that the ladder cannot be shifted by less than one meter. The ladder can only stand in front of some square of the poster. For example, you cannot shift a ladder by half a meter and position it between two squares. Then go up and paint the first character and the second character.
Java 7
standard input
[ "implementation", "greedy" ]
e3a03f3f01a77a1983121bab4218c39c
The first line contains two integers, n and k (1 ≤ k ≤ n ≤ 100) — the number of characters in the slogan and the initial position of the ladder, correspondingly. The next line contains the slogan as n characters written without spaces. Each character of the slogan is either a large English letter, or digit, or one of the characters: '.', '!', ',', '?'.
900
In t lines, print the actions the programmers need to make. In the i-th line print: "LEFT" (without the quotes), if the i-th action was "move the ladder to the left"; "RIGHT" (without the quotes), if the i-th action was "move the ladder to the right"; "PRINT x" (without the quotes), if the i-th action was to "go up the ladder, paint character x, go down the ladder". The painting time (variable t) must be minimum possible. If there are multiple optimal painting plans, you can print any of them.
standard output
PASSED
57b1ddf2ddc6d68e15e0f9ffac4fc8e7
train_002.jsonl
1397837400
The R1 company has recently bought a high rise building in the centre of Moscow for its main office. It's time to decorate the new office, and the first thing to do is to write the company's slogan above the main entrance to the building.The slogan of the company consists of n characters, so the decorators hung a large banner, n meters wide and 1 meter high, divided into n equal squares. The first character of the slogan must be in the first square (the leftmost) of the poster, the second character must be in the second square, and so on.Of course, the R1 programmers want to write the slogan on the poster themselves. To do this, they have a large (and a very heavy) ladder which was put exactly opposite the k-th square of the poster. To draw the i-th character of the slogan on the poster, you need to climb the ladder, standing in front of the i-th square of the poster. This action (along with climbing up and down the ladder) takes one hour for a painter. The painter is not allowed to draw characters in the adjacent squares when the ladder is in front of the i-th square because the uncomfortable position of the ladder may make the characters untidy. Besides, the programmers can move the ladder. In one hour, they can move the ladder either a meter to the right or a meter to the left.Drawing characters and moving the ladder is very tiring, so the programmers want to finish the job in as little time as possible. Develop for them an optimal poster painting plan!
256 megabytes
import java.util.Scanner; public class Input { public static void main(String[] args) { @SuppressWarnings("resource") Scanner in = new Scanner(System.in); int l = in.nextInt(); int p = in.nextInt(); String s = in.next(); if (l%2 == 0) { if (p > l/2) { // On Right Side while (p < l) { print("RIGHT"); p++; } // Reached End. while (p > 0) { print("PRINT " + s.charAt(p-1)); if (p > 1) print("LEFT"); --p; } } else { // On Left Side while (p > 1) { print("LEFT"); --p; } // Reached Start. while (p <= l) { print("PRINT " + s.charAt(p-1)); if (p < l) print("RIGHT"); p++; } } } else { if (p > l/2) { // On Right Side while (p < l) { print("RIGHT"); p++; } // Reached End. while (p > 0) { print("PRINT " + s.charAt(p-1)); if (p > 1) print("LEFT"); --p; } } else { // On Left Side while (p > 1) { print("LEFT"); --p; } // Reached Start. while (p <= l) { print("PRINT " + s.charAt(p-1)); if (p < l) print("RIGHT"); p++; } } } } private static void print(String string) { System.out.println(string); } private static void print(boolean b) { System.out.println(b); } }
Java
["2 2\nR1", "2 1\nR1", "6 4\nGO?GO!"]
1 second
["PRINT 1\nLEFT\nPRINT R", "PRINT R\nRIGHT\nPRINT 1", "RIGHT\nRIGHT\nPRINT !\nLEFT\nPRINT O\nLEFT\nPRINT G\nLEFT\nPRINT ?\nLEFT\nPRINT O\nLEFT\nPRINT G"]
NoteNote that the ladder cannot be shifted by less than one meter. The ladder can only stand in front of some square of the poster. For example, you cannot shift a ladder by half a meter and position it between two squares. Then go up and paint the first character and the second character.
Java 7
standard input
[ "implementation", "greedy" ]
e3a03f3f01a77a1983121bab4218c39c
The first line contains two integers, n and k (1 ≤ k ≤ n ≤ 100) — the number of characters in the slogan and the initial position of the ladder, correspondingly. The next line contains the slogan as n characters written without spaces. Each character of the slogan is either a large English letter, or digit, or one of the characters: '.', '!', ',', '?'.
900
In t lines, print the actions the programmers need to make. In the i-th line print: "LEFT" (without the quotes), if the i-th action was "move the ladder to the left"; "RIGHT" (without the quotes), if the i-th action was "move the ladder to the right"; "PRINT x" (without the quotes), if the i-th action was to "go up the ladder, paint character x, go down the ladder". The painting time (variable t) must be minimum possible. If there are multiple optimal painting plans, you can print any of them.
standard output
PASSED
5f9147893e01169cf43c439fe792a0db
train_002.jsonl
1397837400
The R1 company has recently bought a high rise building in the centre of Moscow for its main office. It's time to decorate the new office, and the first thing to do is to write the company's slogan above the main entrance to the building.The slogan of the company consists of n characters, so the decorators hung a large banner, n meters wide and 1 meter high, divided into n equal squares. The first character of the slogan must be in the first square (the leftmost) of the poster, the second character must be in the second square, and so on.Of course, the R1 programmers want to write the slogan on the poster themselves. To do this, they have a large (and a very heavy) ladder which was put exactly opposite the k-th square of the poster. To draw the i-th character of the slogan on the poster, you need to climb the ladder, standing in front of the i-th square of the poster. This action (along with climbing up and down the ladder) takes one hour for a painter. The painter is not allowed to draw characters in the adjacent squares when the ladder is in front of the i-th square because the uncomfortable position of the ladder may make the characters untidy. Besides, the programmers can move the ladder. In one hour, they can move the ladder either a meter to the right or a meter to the left.Drawing characters and moving the ladder is very tiring, so the programmers want to finish the job in as little time as possible. Develop for them an optimal poster painting plan!
256 megabytes
import java.util.Scanner; import java.io.OutputStream; import java.io.IOException; import java.io.PrintWriter; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the top * @author rabeckiy */ public class Main { public static void main(String[] args) { InputStream inputStream = System.in; OutputStream outputStream = System.out; Scanner in = new Scanner(inputStream); PrintWriter out = new PrintWriter(outputStream); TaskA solver = new TaskA(); solver.solve(1, in, out); out.close(); } } class TaskA { public void solve(int testNumber, Scanner in, PrintWriter out) { int n = in.nextInt(); int k = in.nextInt(); char[] l = in.next().toCharArray(); if(n-k >= k){ for(int j = k; j>1; j--) out.println("LEFT"); out.println("PRINT "+l[0]); for(int j = 1; j<n; j++){ out.println("RIGHT"); out.println("PRINT "+l[j]); } } else { for(int j = k; j<n; j++) out.println("RIGHT"); out.println("PRINT "+l[n-1]); for(int j = n-2; j>=0; j--){ out.println("LEFT"); out.println("PRINT "+l[j]); } } } }
Java
["2 2\nR1", "2 1\nR1", "6 4\nGO?GO!"]
1 second
["PRINT 1\nLEFT\nPRINT R", "PRINT R\nRIGHT\nPRINT 1", "RIGHT\nRIGHT\nPRINT !\nLEFT\nPRINT O\nLEFT\nPRINT G\nLEFT\nPRINT ?\nLEFT\nPRINT O\nLEFT\nPRINT G"]
NoteNote that the ladder cannot be shifted by less than one meter. The ladder can only stand in front of some square of the poster. For example, you cannot shift a ladder by half a meter and position it between two squares. Then go up and paint the first character and the second character.
Java 7
standard input
[ "implementation", "greedy" ]
e3a03f3f01a77a1983121bab4218c39c
The first line contains two integers, n and k (1 ≤ k ≤ n ≤ 100) — the number of characters in the slogan and the initial position of the ladder, correspondingly. The next line contains the slogan as n characters written without spaces. Each character of the slogan is either a large English letter, or digit, or one of the characters: '.', '!', ',', '?'.
900
In t lines, print the actions the programmers need to make. In the i-th line print: "LEFT" (without the quotes), if the i-th action was "move the ladder to the left"; "RIGHT" (without the quotes), if the i-th action was "move the ladder to the right"; "PRINT x" (without the quotes), if the i-th action was to "go up the ladder, paint character x, go down the ladder". The painting time (variable t) must be minimum possible. If there are multiple optimal painting plans, you can print any of them.
standard output
PASSED
73fc98840497eb53e18002dc12c48919
train_002.jsonl
1397837400
The R1 company has recently bought a high rise building in the centre of Moscow for its main office. It's time to decorate the new office, and the first thing to do is to write the company's slogan above the main entrance to the building.The slogan of the company consists of n characters, so the decorators hung a large banner, n meters wide and 1 meter high, divided into n equal squares. The first character of the slogan must be in the first square (the leftmost) of the poster, the second character must be in the second square, and so on.Of course, the R1 programmers want to write the slogan on the poster themselves. To do this, they have a large (and a very heavy) ladder which was put exactly opposite the k-th square of the poster. To draw the i-th character of the slogan on the poster, you need to climb the ladder, standing in front of the i-th square of the poster. This action (along with climbing up and down the ladder) takes one hour for a painter. The painter is not allowed to draw characters in the adjacent squares when the ladder is in front of the i-th square because the uncomfortable position of the ladder may make the characters untidy. Besides, the programmers can move the ladder. In one hour, they can move the ladder either a meter to the right or a meter to the left.Drawing characters and moving the ladder is very tiring, so the programmers want to finish the job in as little time as possible. Develop for them an optimal poster painting plan!
256 megabytes
import java.io.BufferedReader; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.StringTokenizer; import java.util.TreeSet; public class solver { BufferedReader in; PrintWriter out; StringTokenizer tok; String readString() throws IOException{ while (tok==null || !tok.hasMoreTokens()){ try{ tok=new StringTokenizer(in.readLine()); } catch(Exception e){ return null; } } return tok.nextToken(); } int readInt() throws NumberFormatException, IOException{ return Integer.parseInt(readString()); } long readLong() throws NumberFormatException, IOException{ return Long.parseLong(readString()); } double readDouble() throws NumberFormatException, IOException{ return Double.parseDouble(readString()); } final static boolean OJ=System.getProperty("ONLINE_JUDGE")!=null; void init() throws FileNotFoundException{ if (OJ){ in=new BufferedReader(new InputStreamReader(System.in)); out=new PrintWriter(System.out); }else{ in=new BufferedReader(new FileReader("input.txt")); out=new PrintWriter("output.txt"); in=new BufferedReader(new InputStreamReader(System.in)); out=new PrintWriter(System.out); } } int[] iMas(int n) throws NumberFormatException, IOException{ int[] a=new int[n]; for (int i=0;i<n;i++){ a[i]=readInt(); } return a; } int gcd (int a, int b) { if (b == 0) return a; else return gcd (b, a % b); } class Pair implements Comparable<Pair>{ int b; int d; String s; Pair(int x,int y,String s){ b=x; d=y; this.s=s; } @Override public int compareTo(Pair o) { return b-o.b; } } int get(int i,int j,int n){ if (i+j<=n) return i+j; return i+j-n; } void solve() throws IOException{ int n=readInt(); int k=readInt()-1; char[] s=readString().toCharArray(); int i=k; if (i<n-1-i){ boolean[] drow=new boolean[n]; while (i>=0){ out.println("PRINT"+" "+s[i]); drow[i]=true; if (i!=0) out.println("LEFT"); i--; } if (k==n-1) return; i=0; while (i<n-1){ if (i!=n-1) out.println("RIGHT"); i++; if (!drow[i]) out.println("PRINT "+s[i]); } }else{ boolean[] drow=new boolean[n]; while (i<n){ out.println("PRINT"+" "+s[i]); drow[i]=true; if (i!=n-1) out.println("RIGHT"); i++; } if (k==0) return; i=n-1; while (i>0){ out.println("LEFT"); i--; if (!drow[i]) out.println("PRINT "+s[i]); } } } void run() throws NumberFormatException, IOException{ init(); long h=System.currentTimeMillis(); solve(); System.err.println(System.currentTimeMillis()-h); out.close(); } public static void main(String[] args) throws NumberFormatException, IOException { new solver().run(); } }
Java
["2 2\nR1", "2 1\nR1", "6 4\nGO?GO!"]
1 second
["PRINT 1\nLEFT\nPRINT R", "PRINT R\nRIGHT\nPRINT 1", "RIGHT\nRIGHT\nPRINT !\nLEFT\nPRINT O\nLEFT\nPRINT G\nLEFT\nPRINT ?\nLEFT\nPRINT O\nLEFT\nPRINT G"]
NoteNote that the ladder cannot be shifted by less than one meter. The ladder can only stand in front of some square of the poster. For example, you cannot shift a ladder by half a meter and position it between two squares. Then go up and paint the first character and the second character.
Java 7
standard input
[ "implementation", "greedy" ]
e3a03f3f01a77a1983121bab4218c39c
The first line contains two integers, n and k (1 ≤ k ≤ n ≤ 100) — the number of characters in the slogan and the initial position of the ladder, correspondingly. The next line contains the slogan as n characters written without spaces. Each character of the slogan is either a large English letter, or digit, or one of the characters: '.', '!', ',', '?'.
900
In t lines, print the actions the programmers need to make. In the i-th line print: "LEFT" (without the quotes), if the i-th action was "move the ladder to the left"; "RIGHT" (without the quotes), if the i-th action was "move the ladder to the right"; "PRINT x" (without the quotes), if the i-th action was to "go up the ladder, paint character x, go down the ladder". The painting time (variable t) must be minimum possible. If there are multiple optimal painting plans, you can print any of them.
standard output
PASSED
bdef64a04be3ce94b2160d04b8c6e08c
train_002.jsonl
1397837400
The R1 company has recently bought a high rise building in the centre of Moscow for its main office. It's time to decorate the new office, and the first thing to do is to write the company's slogan above the main entrance to the building.The slogan of the company consists of n characters, so the decorators hung a large banner, n meters wide and 1 meter high, divided into n equal squares. The first character of the slogan must be in the first square (the leftmost) of the poster, the second character must be in the second square, and so on.Of course, the R1 programmers want to write the slogan on the poster themselves. To do this, they have a large (and a very heavy) ladder which was put exactly opposite the k-th square of the poster. To draw the i-th character of the slogan on the poster, you need to climb the ladder, standing in front of the i-th square of the poster. This action (along with climbing up and down the ladder) takes one hour for a painter. The painter is not allowed to draw characters in the adjacent squares when the ladder is in front of the i-th square because the uncomfortable position of the ladder may make the characters untidy. Besides, the programmers can move the ladder. In one hour, they can move the ladder either a meter to the right or a meter to the left.Drawing characters and moving the ladder is very tiring, so the programmers want to finish the job in as little time as possible. Develop for them an optimal poster painting plan!
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; public class A { static class Scanner{ BufferedReader br=null; StringTokenizer tk=null; public Scanner(){ br=new BufferedReader(new InputStreamReader(System.in)); } public String next() throws IOException{ while(tk==null || !tk.hasMoreTokens()) tk=new StringTokenizer(br.readLine()); return tk.nextToken(); } public int nextInt() throws NumberFormatException, IOException{ return Integer.valueOf(next()); } } static int K, N; static char[] text; public static void main(String args[]) throws NumberFormatException, IOException{ Scanner sc = new Scanner(); N = sc.nextInt() ; K = sc.nextInt() - 1; text = sc.next().toCharArray(); int left = K; int right = N - 1 - K; if (left < right){ for(int i = 0; i < left; i++) System.out.println("LEFT"); for(int i = 0; i < N; i++){ System.out.println("PRINT " + text[i]); if (i < N - 1) System.out.println("RIGHT"); } } else{ for(int i = 0; i < right; i++) System.out.println("RIGHT"); for(int i = N - 1; i >= 0; i--){ System.out.println("PRINT " + text[i]); if (i > 0) System.out.println("LEFT"); } } } }
Java
["2 2\nR1", "2 1\nR1", "6 4\nGO?GO!"]
1 second
["PRINT 1\nLEFT\nPRINT R", "PRINT R\nRIGHT\nPRINT 1", "RIGHT\nRIGHT\nPRINT !\nLEFT\nPRINT O\nLEFT\nPRINT G\nLEFT\nPRINT ?\nLEFT\nPRINT O\nLEFT\nPRINT G"]
NoteNote that the ladder cannot be shifted by less than one meter. The ladder can only stand in front of some square of the poster. For example, you cannot shift a ladder by half a meter and position it between two squares. Then go up and paint the first character and the second character.
Java 7
standard input
[ "implementation", "greedy" ]
e3a03f3f01a77a1983121bab4218c39c
The first line contains two integers, n and k (1 ≤ k ≤ n ≤ 100) — the number of characters in the slogan and the initial position of the ladder, correspondingly. The next line contains the slogan as n characters written without spaces. Each character of the slogan is either a large English letter, or digit, or one of the characters: '.', '!', ',', '?'.
900
In t lines, print the actions the programmers need to make. In the i-th line print: "LEFT" (without the quotes), if the i-th action was "move the ladder to the left"; "RIGHT" (without the quotes), if the i-th action was "move the ladder to the right"; "PRINT x" (without the quotes), if the i-th action was to "go up the ladder, paint character x, go down the ladder". The painting time (variable t) must be minimum possible. If there are multiple optimal painting plans, you can print any of them.
standard output
PASSED
6dcb29905bddc634f114c196f38838d3
train_002.jsonl
1397837400
The R1 company has recently bought a high rise building in the centre of Moscow for its main office. It's time to decorate the new office, and the first thing to do is to write the company's slogan above the main entrance to the building.The slogan of the company consists of n characters, so the decorators hung a large banner, n meters wide and 1 meter high, divided into n equal squares. The first character of the slogan must be in the first square (the leftmost) of the poster, the second character must be in the second square, and so on.Of course, the R1 programmers want to write the slogan on the poster themselves. To do this, they have a large (and a very heavy) ladder which was put exactly opposite the k-th square of the poster. To draw the i-th character of the slogan on the poster, you need to climb the ladder, standing in front of the i-th square of the poster. This action (along with climbing up and down the ladder) takes one hour for a painter. The painter is not allowed to draw characters in the adjacent squares when the ladder is in front of the i-th square because the uncomfortable position of the ladder may make the characters untidy. Besides, the programmers can move the ladder. In one hour, they can move the ladder either a meter to the right or a meter to the left.Drawing characters and moving the ladder is very tiring, so the programmers want to finish the job in as little time as possible. Develop for them an optimal poster painting plan!
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class RoundOne { public static void main(String[] args){ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String first = ""; String second = ""; try { first = br.readLine(); second = br.readLine(); } catch (IOException e) { e.printStackTrace(); } String[] in = first.split(" "); printTheWay(Integer.parseInt(in[0]),Integer.parseInt(in[1])-1,second); } public static void printTheWay(int length,int begin,String word){ if(begin<length/2.0){ //go left while(begin>0){ System.out.println("LEFT"); begin--; } printFromLeft(word); }else{ //go right while(begin<length-1){ System.out.println("RIGHT"); begin++; } printFromRight(word); } } public static void printFromLeft(String word){ for(int i=0;i<word.length();i++){ System.out.println("PRINT "+word.charAt(i)); if(i<word.length()-1){ System.out.println("RIGHT"); } } } public static void printFromRight(String word){ for(int i=word.length()-1;i>=0;i--){ System.out.println("PRINT "+word.charAt(i)); if(i>0){ System.out.println("LEFT"); } } } }
Java
["2 2\nR1", "2 1\nR1", "6 4\nGO?GO!"]
1 second
["PRINT 1\nLEFT\nPRINT R", "PRINT R\nRIGHT\nPRINT 1", "RIGHT\nRIGHT\nPRINT !\nLEFT\nPRINT O\nLEFT\nPRINT G\nLEFT\nPRINT ?\nLEFT\nPRINT O\nLEFT\nPRINT G"]
NoteNote that the ladder cannot be shifted by less than one meter. The ladder can only stand in front of some square of the poster. For example, you cannot shift a ladder by half a meter and position it between two squares. Then go up and paint the first character and the second character.
Java 7
standard input
[ "implementation", "greedy" ]
e3a03f3f01a77a1983121bab4218c39c
The first line contains two integers, n and k (1 ≤ k ≤ n ≤ 100) — the number of characters in the slogan and the initial position of the ladder, correspondingly. The next line contains the slogan as n characters written without spaces. Each character of the slogan is either a large English letter, or digit, or one of the characters: '.', '!', ',', '?'.
900
In t lines, print the actions the programmers need to make. In the i-th line print: "LEFT" (without the quotes), if the i-th action was "move the ladder to the left"; "RIGHT" (without the quotes), if the i-th action was "move the ladder to the right"; "PRINT x" (without the quotes), if the i-th action was to "go up the ladder, paint character x, go down the ladder". The painting time (variable t) must be minimum possible. If there are multiple optimal painting plans, you can print any of them.
standard output
PASSED
d14b47a755bf37777a6233c0cd9b3074
train_002.jsonl
1397837400
The R1 company has recently bought a high rise building in the centre of Moscow for its main office. It's time to decorate the new office, and the first thing to do is to write the company's slogan above the main entrance to the building.The slogan of the company consists of n characters, so the decorators hung a large banner, n meters wide and 1 meter high, divided into n equal squares. The first character of the slogan must be in the first square (the leftmost) of the poster, the second character must be in the second square, and so on.Of course, the R1 programmers want to write the slogan on the poster themselves. To do this, they have a large (and a very heavy) ladder which was put exactly opposite the k-th square of the poster. To draw the i-th character of the slogan on the poster, you need to climb the ladder, standing in front of the i-th square of the poster. This action (along with climbing up and down the ladder) takes one hour for a painter. The painter is not allowed to draw characters in the adjacent squares when the ladder is in front of the i-th square because the uncomfortable position of the ladder may make the characters untidy. Besides, the programmers can move the ladder. In one hour, they can move the ladder either a meter to the right or a meter to the left.Drawing characters and moving the ladder is very tiring, so the programmers want to finish the job in as little time as possible. Develop for them an optimal poster painting plan!
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.lang.reflect.Constructor; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.InputMismatchException; import java.util.StringTokenizer; public class CodeE { public static void main(String[] args) { Scanner sc = new SuperScanner(); int n = sc.nextInt(); int k = sc.nextInt() - 1; char[] input = sc.next().toCharArray(); int right = (n - 1) - k; int left = k; if (right > left) { for (int i = 0; i < left; i++) { System.out.println("LEFT"); } System.out.println("PRINT " + input[0]); for (int i = 1; i < n; i++) { System.out.println("RIGHT"); System.out.println("PRINT " + input[i]); } } else { for (int i = 0; i < right; i++) { System.out.println("RIGHT"); } System.out.println("PRINT " + input[n - 1]); for (int i = n - 2; i >= 0; i--) { System.out.println("LEFT"); System.out.println("PRINT " + input[i]); } } } static class SuperScanner extends Scanner { private InputStream stream; private byte[] buf = new byte[8096]; private int curChar; private int numChars; public SuperScanner() { this.stream = System.in; } public int read() { if (numChars == -1) throw new InputMismatchException(); if (curChar >= numChars) { curChar = 0; try { numChars = stream.read(buf); } catch (IOException e) { throw new InputMismatchException(); } if (numChars <= 0) return -1; } return buf[curChar++]; } public static boolean isWhitespace(int c) { return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1; } private final StringBuilder sb = new StringBuilder(); @Override public String next() { int c = read(); while (isWhitespace(c)) { if (c == -1) { return null; } c = read(); } sb.setLength(0); do { sb.append((char) c); c = read(); } while (!isWhitespace(c)); return sb.toString(); } @Override public int nextInt() { int c = read(); while (isWhitespace(c)) c = read(); int sgn = 1; if (c == '-') { sgn = -1; c = read(); } int res = 0; do { if (c < '0' || c > '9') throw new InputMismatchException(); res = (res << 3) + (res << 1); res += c - '0'; c = read(); } while (!isWhitespace(c)); return res * sgn; } @Override public long nextLong() { int c = read(); while (isWhitespace(c)) c = read(); int sgn = 1; if (c == '-') { sgn = -1; c = read(); } long res = 0; do { if (c < '0' || c > '9') throw new InputMismatchException(); res = (res << 3) + (res << 1); res += c - '0'; c = read(); } while (!isWhitespace(c)); return res * sgn; } } static class Scanner { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(""); public String nextLine() { try { return br.readLine(); } catch (Exception e) { throw (new RuntimeException()); } } public int nextIntOrQuit() { Integer n = nextInteger(); if (n == null) { System.exit(0); } return n.intValue(); } public String next() { while (!st.hasMoreTokens()) { String l = nextLine(); if (l == null) return null; st = new StringTokenizer(l); } return st.nextToken(); } public int nextInt() { return Integer.parseInt(next()); } public long nextLong() { return Long.parseLong(next()); } public double nextDouble() { return Double.parseDouble(next()); } public int[] nextIntArray(int n) { int[] res = new int[n]; for (int i = 0; i < res.length; i++) res[i] = nextInt(); return res; } public long[] nextLongArray(int n) { long[] res = new long[n]; for (int i = 0; i < res.length; i++) res[i] = nextLong(); return res; } public double[] nextDoubleArray(int n) { double[] res = new double[n]; for (int i = 0; i < res.length; i++) res[i] = nextDouble(); return res; } public void sortIntArray(int[] array) { Integer[] vals = new Integer[array.length]; for (int i = 0; i < array.length; i++) vals[i] = array[i]; Arrays.sort(vals); for (int i = 0; i < array.length; i++) array[i] = vals[i]; } public void sortLongArray(long[] array) { Long[] vals = new Long[array.length]; for (int i = 0; i < array.length; i++) vals[i] = array[i]; Arrays.sort(vals); for (int i = 0; i < array.length; i++) array[i] = vals[i]; } public void sortDoubleArray(double[] array) { Double[] vals = new Double[array.length]; for (int i = 0; i < array.length; i++) vals[i] = array[i]; Arrays.sort(vals); for (int i = 0; i < array.length; i++) array[i] = vals[i]; } public String[] nextStringArray(int n) { String[] vals = new String[n]; for (int i = 0; i < n; i++) vals[i] = next(); return vals; } public Integer nextInteger() { String s = next(); if (s == null) return null; return Integer.parseInt(s); } public int[][] nextIntMatrix(int n, int m) { int[][] ans = new int[n][]; for (int i = 0; i < n; i++) ans[i] = nextIntArray(m); return ans; } public char[][] nextGrid(int r) { char[][] grid = new char[r][]; for (int i = 0; i < r; i++) grid[i] = next().toCharArray(); return grid; } public static <T> T fill(T arreglo, int val) { if (arreglo instanceof Object[]) { Object[] a = (Object[]) arreglo; for (Object x : a) fill(x, val); } else if (arreglo instanceof int[]) Arrays.fill((int[]) arreglo, val); else if (arreglo instanceof double[]) Arrays.fill((double[]) arreglo, val); else if (arreglo instanceof long[]) Arrays.fill((long[]) arreglo, val); return arreglo; } public <T> T[] nextObjectArray(Class<T> clazz, int size) { @SuppressWarnings("unchecked") T[] result = (T[]) java.lang.reflect.Array.newInstance(clazz, size); for (int c = 0; c < 3; c++) { Constructor<T> constructor; try { if (c == 0) constructor = clazz.getDeclaredConstructor(Scanner.class, Integer.TYPE); else if (c == 1) constructor = clazz.getDeclaredConstructor(Scanner.class); else constructor = clazz.getDeclaredConstructor(); } catch (Exception e) { continue; } try { for (int i = 0; i < result.length; i++) { if (c == 0) result[i] = constructor.newInstance(this, i); else if (c == 1) result[i] = constructor.newInstance(this); else result[i] = constructor.newInstance(); } } catch (Exception e) { throw new RuntimeException(e); } return result; } throw new RuntimeException("Constructor not found"); } public void printLine(int... vals) { if (vals.length == 0) System.out.println(); else { System.out.print(vals[0]); for (int i = 1; i < vals.length; i++) System.out.print(" ".concat(String.valueOf(vals[i]))); System.out.println(); } } public void printLine(long... vals) { if (vals.length == 0) System.out.println(); else { System.out.print(vals[0]); for (int i = 1; i < vals.length; i++) System.out.print(" ".concat(String.valueOf(vals[i]))); System.out.println(); } } public void printLine(double... vals) { if (vals.length == 0) System.out.println(); else { System.out.print(vals[0]); for (int i = 1; i < vals.length; i++) System.out.print(" ".concat(String.valueOf(vals[i]))); System.out.println(); } } public void printLine(int prec, double... vals) { if (vals.length == 0) System.out.println(); else { System.out.printf("%." + prec + "f", vals[0]); for (int i = 1; i < vals.length; i++) System.out.printf(" %." + prec + "f", vals[i]); System.out.println(); } } public Collection<Integer> wrap(int[] as) { ArrayList<Integer> ans = new ArrayList<Integer>(); for (int i : as) ans.add(i); return ans; } public int[] unwrap(Collection<Integer> collection) { int[] vals = new int[collection.size()]; int index = 0; for (int i : collection) vals[index++] = i; return vals; } } }
Java
["2 2\nR1", "2 1\nR1", "6 4\nGO?GO!"]
1 second
["PRINT 1\nLEFT\nPRINT R", "PRINT R\nRIGHT\nPRINT 1", "RIGHT\nRIGHT\nPRINT !\nLEFT\nPRINT O\nLEFT\nPRINT G\nLEFT\nPRINT ?\nLEFT\nPRINT O\nLEFT\nPRINT G"]
NoteNote that the ladder cannot be shifted by less than one meter. The ladder can only stand in front of some square of the poster. For example, you cannot shift a ladder by half a meter and position it between two squares. Then go up and paint the first character and the second character.
Java 7
standard input
[ "implementation", "greedy" ]
e3a03f3f01a77a1983121bab4218c39c
The first line contains two integers, n and k (1 ≤ k ≤ n ≤ 100) — the number of characters in the slogan and the initial position of the ladder, correspondingly. The next line contains the slogan as n characters written without spaces. Each character of the slogan is either a large English letter, or digit, or one of the characters: '.', '!', ',', '?'.
900
In t lines, print the actions the programmers need to make. In the i-th line print: "LEFT" (without the quotes), if the i-th action was "move the ladder to the left"; "RIGHT" (without the quotes), if the i-th action was "move the ladder to the right"; "PRINT x" (without the quotes), if the i-th action was to "go up the ladder, paint character x, go down the ladder". The painting time (variable t) must be minimum possible. If there are multiple optimal painting plans, you can print any of them.
standard output
PASSED
3c2d0c737b97ecec338cd408927e916e
train_002.jsonl
1397837400
The R1 company has recently bought a high rise building in the centre of Moscow for its main office. It's time to decorate the new office, and the first thing to do is to write the company's slogan above the main entrance to the building.The slogan of the company consists of n characters, so the decorators hung a large banner, n meters wide and 1 meter high, divided into n equal squares. The first character of the slogan must be in the first square (the leftmost) of the poster, the second character must be in the second square, and so on.Of course, the R1 programmers want to write the slogan on the poster themselves. To do this, they have a large (and a very heavy) ladder which was put exactly opposite the k-th square of the poster. To draw the i-th character of the slogan on the poster, you need to climb the ladder, standing in front of the i-th square of the poster. This action (along with climbing up and down the ladder) takes one hour for a painter. The painter is not allowed to draw characters in the adjacent squares when the ladder is in front of the i-th square because the uncomfortable position of the ladder may make the characters untidy. Besides, the programmers can move the ladder. In one hour, they can move the ladder either a meter to the right or a meter to the left.Drawing characters and moving the ladder is very tiring, so the programmers want to finish the job in as little time as possible. Develop for them an optimal poster painting plan!
256 megabytes
import java.io.*; import java.util.*; public class Poster { public static void main(String[] args) throws IOException { BufferedReader f = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(f.readLine()); int n = Integer.parseInt(st.nextToken()); int k = Integer.parseInt(st.nextToken()); String str = f.readLine(); if (k <= n/2) { for (int i = 0; i < k-1; i++) System.out.println("LEFT"); System.out.println("PRINT " + str.charAt(0)); for (int i = 1; i < n; i++) { System.out.println("RIGHT"); System.out.println("PRINT " + str.charAt(i)); } } else { for (int i = 0; i < n-k; i++) System.out.println("RIGHT"); System.out.println("PRINT " + str.charAt(n-1)); for (int i = n-2; i >= 0; i--) { System.out.println("LEFT"); System.out.println("PRINT " + str.charAt(i)); } } } }
Java
["2 2\nR1", "2 1\nR1", "6 4\nGO?GO!"]
1 second
["PRINT 1\nLEFT\nPRINT R", "PRINT R\nRIGHT\nPRINT 1", "RIGHT\nRIGHT\nPRINT !\nLEFT\nPRINT O\nLEFT\nPRINT G\nLEFT\nPRINT ?\nLEFT\nPRINT O\nLEFT\nPRINT G"]
NoteNote that the ladder cannot be shifted by less than one meter. The ladder can only stand in front of some square of the poster. For example, you cannot shift a ladder by half a meter and position it between two squares. Then go up and paint the first character and the second character.
Java 7
standard input
[ "implementation", "greedy" ]
e3a03f3f01a77a1983121bab4218c39c
The first line contains two integers, n and k (1 ≤ k ≤ n ≤ 100) — the number of characters in the slogan and the initial position of the ladder, correspondingly. The next line contains the slogan as n characters written without spaces. Each character of the slogan is either a large English letter, or digit, or one of the characters: '.', '!', ',', '?'.
900
In t lines, print the actions the programmers need to make. In the i-th line print: "LEFT" (without the quotes), if the i-th action was "move the ladder to the left"; "RIGHT" (without the quotes), if the i-th action was "move the ladder to the right"; "PRINT x" (without the quotes), if the i-th action was to "go up the ladder, paint character x, go down the ladder". The painting time (variable t) must be minimum possible. If there are multiple optimal painting plans, you can print any of them.
standard output
PASSED
d2787435e5ed38077aebb90ede4dc835
train_002.jsonl
1397837400
The R1 company has recently bought a high rise building in the centre of Moscow for its main office. It's time to decorate the new office, and the first thing to do is to write the company's slogan above the main entrance to the building.The slogan of the company consists of n characters, so the decorators hung a large banner, n meters wide and 1 meter high, divided into n equal squares. The first character of the slogan must be in the first square (the leftmost) of the poster, the second character must be in the second square, and so on.Of course, the R1 programmers want to write the slogan on the poster themselves. To do this, they have a large (and a very heavy) ladder which was put exactly opposite the k-th square of the poster. To draw the i-th character of the slogan on the poster, you need to climb the ladder, standing in front of the i-th square of the poster. This action (along with climbing up and down the ladder) takes one hour for a painter. The painter is not allowed to draw characters in the adjacent squares when the ladder is in front of the i-th square because the uncomfortable position of the ladder may make the characters untidy. Besides, the programmers can move the ladder. In one hour, they can move the ladder either a meter to the right or a meter to the left.Drawing characters and moving the ladder is very tiring, so the programmers want to finish the job in as little time as possible. Develop for them an optimal poster painting plan!
256 megabytes
import java.util.* ; import java.io.* ; import java.util.regex.* ; import java.text.* ; import java.math.* ; public class Main { public static void main( String[] args ) { InputStream isObj ; OutputStream osObj ; InputReader irObj ; PrintWriter pwObj ; String inputFileName , outputFileName ; File fObj1 , fObj2 ; int T , ind ; boolean hasMoreInput , hasTestCases ; ProblemSolver psObj ; //only variable to be changed here is hasTestCases and osObj(optional for file output) hasTestCases = ProblemSolver.HAS_TEST_CASES ; isObj = System.in ; osObj = System.out ; inputFileName = ProblemSolver.INPUT_FILE_NAME ; outputFileName = ProblemSolver.OUTPUT_FILE_NAME ; try { fObj1 = new File( System.getProperty( "user.dir" ).toString() + "\\" + inputFileName ) ; fObj2 = new File( System.getProperty( "user.dir" ).toString() + "\\" + outputFileName ) ; if( fObj1.exists() == false ) { fObj1 = new File( System.getProperty( "user.dir" ).toString() + "\\src\\" + inputFileName ) ; fObj2 = new File( System.getProperty( "user.dir" ).toString() + "\\src\\" + outputFileName ) ; } isObj = new FileInputStream( fObj1 ) ; if( ProblemSolver.DO_OUTPUT_TO_FILE == true ) { osObj = new FileOutputStream( fObj2 ) ; } } catch( Exception ex ) { ex.printStackTrace() ; isObj = System.in ; osObj = System.out ; } irObj = new InputReader( isObj ) ; pwObj = new PrintWriter( osObj ) ; try { psObj = new ProblemSolver() ; if( hasTestCases == true ) { //for input with test cases T = irObj.nextInt() ; for( ind = 1 ; ind <= T ; ind++ ) { psObj.clearPerCase() ; psObj.getInput( irObj ) ; psObj.solveCase( pwObj ) ; } } else { //for end of file input for( ind = 1 ; ; ind++ ) { psObj.clearPerCase() ; hasMoreInput = psObj.getInput( irObj ) ; if( hasMoreInput == false ) { break ; } psObj.solveCase( pwObj ) ; } } pwObj.flush() ; isObj.close() ; osObj.close() ; } catch( Exception ex ) { ex.printStackTrace() ; throw new RuntimeException( ex ) ; } finally { pwObj.close() ; } } } class ProblemSolver { public static final boolean HAS_TEST_CASES = false ; public static final String INPUT_FILE_NAME = "test.in" ; public static final String OUTPUT_FILE_NAME = "out.txt" ; public static final boolean DO_OUTPUT_TO_FILE = false ; public void solveCase( PrintWriter pwObj ) { int i , j , a ; int res ; res = 0 ; this.n = this.s.length() ; Arrays.fill( this.arr , 0 ) ; this.cn = 0 ; if( Math.abs( 1 - this.k ) > Math.abs( this.k - this.n ) ) { for( i = this.k - 1 ; i < this.n ; i++ ) { if( this.arr[ i ] == 0 ) { pwObj.println( "PRINT " + this.s.charAt( i ) ) ; this.arr[ i ] = 1 ; this.cn++ ; } if( i != this.n - 1 ) { pwObj.println( "RIGHT" ) ; } } if( this.k - 1 != 0 ) { for( i = this.n - 2 ; i >= 0 ; i-- ) { pwObj.println( "LEFT" ) ; if( this.arr[ i ] == 0 ) { pwObj.println( "PRINT " + this.s.charAt( i ) ) ; this.arr[ i ] = 1 ; this.cn++ ; } } } } else { for( i = this.k - 1 ; i >= 0 ; i-- ) { if( this.arr[ i ] == 0 ) { pwObj.println( "PRINT " + this.s.charAt( i ) ) ; this.arr[ i ] = 1 ; this.cn++ ; } if( i != 0 ) { pwObj.println( "LEFT" ) ; } } if( this.k - 1 != this.n - 1 ) { for( i = 1 ; i < this.n ; i++ ) { pwObj.println( "RIGHT" ) ; if( this.arr[ i ] == 0 ) { pwObj.println( "PRINT " + this.s.charAt( i ) ) ; this.arr[ i ] = 1 ; this.cn++ ; } } } } } private void init() { //default values this.lim1 = 100010 ; this.lim2 = 110 ; this.cc = 1 ; this.ind = 0 ; this.declareArrays() ; this.fillAllArrays() ; } public boolean getInput( InputReader irObj ) { int i ; try { this.n = irObj.nextInt() ; } catch( Exception ex ) { return false ; } this.k = irObj.nextInt() ; this.s = irObj.nextString() ; return true ; } private int lim1 , lim2 , cn , ind , cc , n , k ; private String s ; private String[] srr ; private int[] arr , brr ; private Node[] nrr ; private long[] lrr ; private int[][] memo , done ; private ArrayList< Integer >[] adj_list ; public void clearPerCase() { this.incrementInd() ; this.incrementCc() ; this.n = 0 ; this.cn = 0 ; } private void declareArrays() { //array declarations this.arr = new int[ this.lim1 ] ; this.brr = new int[ this.lim1 ] ; this.lrr = new long[ this.lim1 ] ; this.srr = new String[ this.lim1 ] ; this.nrr = new Node[ this.lim1 ] ; this.memo = new int[ this.lim2 ][ this.lim2 ] ; this.done = new int[ this.lim2 ][ this.lim2 ] ; this.adj_list = new ArrayList[ this.lim1 ] ; this.s = new String( "" ) ; } private void fillAllArrays() { int i ; //array initiations Arrays.fill( this.arr , 0 ) ; Arrays.fill( this.brr , 0 ) ; Arrays.fill( this.lrr , 0 ) ; for( int zrr[] : this.memo ) { Arrays.fill( zrr , -1 ) ; } for( int zrr[] : this.done ) { Arrays.fill( zrr , 0 ) ; } for( i = 0 ; i < this.lim1 ; i++ ) { this.srr[ i ] = new String( "" ) ; this.nrr[ i ] = new Node( Integer.MIN_VALUE , Integer.MIN_VALUE ) ; this.adj_list[ i ] = new ArrayList< Integer >() ; } } private void incrementInd() { this.ind++ ; } public void setCn( int c ) { this.cn = c ; } public void incrementCn() { this.cn++ ; } public void incrementCc() { this.cc++ ; } public int getCn() { return this.cn ; } public ProblemSolver() { this.init() ; } } class Node implements Comparable< Node > { private int v , f ; private Node() { } public Node( int vParam , int fParam ) { this.v = vParam ; this.f = fParam ; } public void setV( int vParam ) { this.v = vParam ; } public void setF( int fParam ) { this.f = fParam ; } public int getV() { return this.v ; } public int getF() { return this.f ; } public int compareTo( Node nParam ) { return this.getV() - nParam.getV() ; } } class InputReader { private BufferedReader reader ; private StringTokenizer tokenizer ; public InputReader( InputStream stream ) { this.reader = new BufferedReader( new InputStreamReader( stream ) ) ; this.tokenizer = null ; } private String next( int fl ) { while( this.tokenizer == null || ! this.tokenizer.hasMoreTokens() ) { try { this.tokenizer = new StringTokenizer( this.reader.readLine() ) ; } catch( IOException e ) { throw new RuntimeException( e ) ; } } String s ; s = "" ; if( fl == 1 ) { s = this.tokenizer.nextToken() ; } return s ; } public String nextLine() { this.next( 0 ) ; int fl ; String line ; line = "" ; fl = 0 ; if( this.tokenizer != null ) { while( this.tokenizer.hasMoreTokens() ) { if( fl == 1 ) { line += " " ; } fl = 1 ; line += this.tokenizer.nextToken() ; } } return line ; } public int nextInt() { return Integer.parseInt( this.next( 1 ) ) ; } public long nextLong() { return Long.parseLong( this.next( 1 ) ) ; } public double nextDouble() { return Double.parseDouble( this.next( 1 ) ) ; } public String nextString() { return this.next( 1 ) ; } }
Java
["2 2\nR1", "2 1\nR1", "6 4\nGO?GO!"]
1 second
["PRINT 1\nLEFT\nPRINT R", "PRINT R\nRIGHT\nPRINT 1", "RIGHT\nRIGHT\nPRINT !\nLEFT\nPRINT O\nLEFT\nPRINT G\nLEFT\nPRINT ?\nLEFT\nPRINT O\nLEFT\nPRINT G"]
NoteNote that the ladder cannot be shifted by less than one meter. The ladder can only stand in front of some square of the poster. For example, you cannot shift a ladder by half a meter and position it between two squares. Then go up and paint the first character and the second character.
Java 7
standard input
[ "implementation", "greedy" ]
e3a03f3f01a77a1983121bab4218c39c
The first line contains two integers, n and k (1 ≤ k ≤ n ≤ 100) — the number of characters in the slogan and the initial position of the ladder, correspondingly. The next line contains the slogan as n characters written without spaces. Each character of the slogan is either a large English letter, or digit, or one of the characters: '.', '!', ',', '?'.
900
In t lines, print the actions the programmers need to make. In the i-th line print: "LEFT" (without the quotes), if the i-th action was "move the ladder to the left"; "RIGHT" (without the quotes), if the i-th action was "move the ladder to the right"; "PRINT x" (without the quotes), if the i-th action was to "go up the ladder, paint character x, go down the ladder". The painting time (variable t) must be minimum possible. If there are multiple optimal painting plans, you can print any of them.
standard output
PASSED
08ebb9ea4d7957023d84072972949fc9
train_002.jsonl
1397837400
The R1 company has recently bought a high rise building in the centre of Moscow for its main office. It's time to decorate the new office, and the first thing to do is to write the company's slogan above the main entrance to the building.The slogan of the company consists of n characters, so the decorators hung a large banner, n meters wide and 1 meter high, divided into n equal squares. The first character of the slogan must be in the first square (the leftmost) of the poster, the second character must be in the second square, and so on.Of course, the R1 programmers want to write the slogan on the poster themselves. To do this, they have a large (and a very heavy) ladder which was put exactly opposite the k-th square of the poster. To draw the i-th character of the slogan on the poster, you need to climb the ladder, standing in front of the i-th square of the poster. This action (along with climbing up and down the ladder) takes one hour for a painter. The painter is not allowed to draw characters in the adjacent squares when the ladder is in front of the i-th square because the uncomfortable position of the ladder may make the characters untidy. Besides, the programmers can move the ladder. In one hour, they can move the ladder either a meter to the right or a meter to the left.Drawing characters and moving the ladder is very tiring, so the programmers want to finish the job in as little time as possible. Develop for them an optimal poster painting plan!
256 megabytes
import java.io.BufferedReader; import java.io.PrintWriter; import java.io.InputStreamReader; import java.util.StringTokenizer; public class CF412A { static BufferedReader in; static PrintWriter out; static StringTokenizer st; public static void main(String[] args) throws Exception { in = new BufferedReader(new InputStreamReader(System.in)); out = new PrintWriter(System.out); st = new StringTokenizer(in.readLine()); int left = 0; int right = readInt() - 1; int position = readInt() - 1; char[] slogan = readString().toCharArray(); // Move to closest edge and print int distanceLeft = position - left; int distanceRight = right - position; if (distanceLeft < distanceRight) { while (position-- > left) out.println("LEFT"); while (position++ < right) { out.println("PRINT " + slogan[position]); if (position < right) out.println("RIGHT"); } } else { while (position++ < right) out.println("RIGHT"); while (position-- > left) { out.println("PRINT " + slogan[position]); if (position > left) out.println("LEFT"); } } out.flush(); } static int readInt() throws Exception { while (!st.hasMoreTokens()) nextLine(); return Integer.parseInt(st.nextToken()); } static String readString() throws Exception { while (!st.hasMoreTokens()) nextLine(); return st.nextToken(); } static void nextLine() throws Exception { st = new StringTokenizer(in.readLine()); } }
Java
["2 2\nR1", "2 1\nR1", "6 4\nGO?GO!"]
1 second
["PRINT 1\nLEFT\nPRINT R", "PRINT R\nRIGHT\nPRINT 1", "RIGHT\nRIGHT\nPRINT !\nLEFT\nPRINT O\nLEFT\nPRINT G\nLEFT\nPRINT ?\nLEFT\nPRINT O\nLEFT\nPRINT G"]
NoteNote that the ladder cannot be shifted by less than one meter. The ladder can only stand in front of some square of the poster. For example, you cannot shift a ladder by half a meter and position it between two squares. Then go up and paint the first character and the second character.
Java 7
standard input
[ "implementation", "greedy" ]
e3a03f3f01a77a1983121bab4218c39c
The first line contains two integers, n and k (1 ≤ k ≤ n ≤ 100) — the number of characters in the slogan and the initial position of the ladder, correspondingly. The next line contains the slogan as n characters written without spaces. Each character of the slogan is either a large English letter, or digit, or one of the characters: '.', '!', ',', '?'.
900
In t lines, print the actions the programmers need to make. In the i-th line print: "LEFT" (without the quotes), if the i-th action was "move the ladder to the left"; "RIGHT" (without the quotes), if the i-th action was "move the ladder to the right"; "PRINT x" (without the quotes), if the i-th action was to "go up the ladder, paint character x, go down the ladder". The painting time (variable t) must be minimum possible. If there are multiple optimal painting plans, you can print any of them.
standard output
PASSED
d13a63a3a0e7d33909cf2bb9903d2c83
train_002.jsonl
1397837400
The R1 company has recently bought a high rise building in the centre of Moscow for its main office. It's time to decorate the new office, and the first thing to do is to write the company's slogan above the main entrance to the building.The slogan of the company consists of n characters, so the decorators hung a large banner, n meters wide and 1 meter high, divided into n equal squares. The first character of the slogan must be in the first square (the leftmost) of the poster, the second character must be in the second square, and so on.Of course, the R1 programmers want to write the slogan on the poster themselves. To do this, they have a large (and a very heavy) ladder which was put exactly opposite the k-th square of the poster. To draw the i-th character of the slogan on the poster, you need to climb the ladder, standing in front of the i-th square of the poster. This action (along with climbing up and down the ladder) takes one hour for a painter. The painter is not allowed to draw characters in the adjacent squares when the ladder is in front of the i-th square because the uncomfortable position of the ladder may make the characters untidy. Besides, the programmers can move the ladder. In one hour, they can move the ladder either a meter to the right or a meter to the left.Drawing characters and moving the ladder is very tiring, so the programmers want to finish the job in as little time as possible. Develop for them an optimal poster painting plan!
256 megabytes
import java.io.*; public class Poster { public static void main(String [] args) throws Throwable{ BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); String nk=""; nk=br.readLine(); String [] str=nk.split(" "); int n=Integer.parseInt(str[0]); int k=Integer.parseInt(str[1]); nk=br.readLine(); StringBuilder Str=new StringBuilder(); if(k>n/2){ for(int i=k; i<n; i++){ Str.append("RIGHT\n"); } for(int i=n; i>0; i--){ Str.append("PRINT "+nk.charAt(i-1)+"\n"); if(i>1) Str.append("LEFT\n"); } }else{ for(int i=k; i>1; i--){ Str.append("LEFT\n"); } for(int i=1; i<=n; i++){ Str.append("PRINT "+nk.charAt(i-1)+"\n"); if(i<n) Str.append("RIGHT\n"); } } System.out.println(Str); } }
Java
["2 2\nR1", "2 1\nR1", "6 4\nGO?GO!"]
1 second
["PRINT 1\nLEFT\nPRINT R", "PRINT R\nRIGHT\nPRINT 1", "RIGHT\nRIGHT\nPRINT !\nLEFT\nPRINT O\nLEFT\nPRINT G\nLEFT\nPRINT ?\nLEFT\nPRINT O\nLEFT\nPRINT G"]
NoteNote that the ladder cannot be shifted by less than one meter. The ladder can only stand in front of some square of the poster. For example, you cannot shift a ladder by half a meter and position it between two squares. Then go up and paint the first character and the second character.
Java 7
standard input
[ "implementation", "greedy" ]
e3a03f3f01a77a1983121bab4218c39c
The first line contains two integers, n and k (1 ≤ k ≤ n ≤ 100) — the number of characters in the slogan and the initial position of the ladder, correspondingly. The next line contains the slogan as n characters written without spaces. Each character of the slogan is either a large English letter, or digit, or one of the characters: '.', '!', ',', '?'.
900
In t lines, print the actions the programmers need to make. In the i-th line print: "LEFT" (without the quotes), if the i-th action was "move the ladder to the left"; "RIGHT" (without the quotes), if the i-th action was "move the ladder to the right"; "PRINT x" (without the quotes), if the i-th action was to "go up the ladder, paint character x, go down the ladder". The painting time (variable t) must be minimum possible. If there are multiple optimal painting plans, you can print any of them.
standard output
PASSED
f9bfc95a53a8baae0fae5e6e10ca70ca
train_002.jsonl
1397837400
The R1 company has recently bought a high rise building in the centre of Moscow for its main office. It's time to decorate the new office, and the first thing to do is to write the company's slogan above the main entrance to the building.The slogan of the company consists of n characters, so the decorators hung a large banner, n meters wide and 1 meter high, divided into n equal squares. The first character of the slogan must be in the first square (the leftmost) of the poster, the second character must be in the second square, and so on.Of course, the R1 programmers want to write the slogan on the poster themselves. To do this, they have a large (and a very heavy) ladder which was put exactly opposite the k-th square of the poster. To draw the i-th character of the slogan on the poster, you need to climb the ladder, standing in front of the i-th square of the poster. This action (along with climbing up and down the ladder) takes one hour for a painter. The painter is not allowed to draw characters in the adjacent squares when the ladder is in front of the i-th square because the uncomfortable position of the ladder may make the characters untidy. Besides, the programmers can move the ladder. In one hour, they can move the ladder either a meter to the right or a meter to the left.Drawing characters and moving the ladder is very tiring, so the programmers want to finish the job in as little time as possible. Develop for them an optimal poster painting plan!
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.StringTokenizer; public class A { public static void main(String[] args) throws IOException { br = new BufferedReader(new InputStreamReader(System.in)); out = new PrintWriter(System.out); sc = new StringTokenizer(""); int n = nxtInt(); int k = nxtInt() - 1; char[] s = nxtCharArr(); int left = k; int right = n - k - 1; if (left < right) { while (left-- > 0) out.println("LEFT"); out.println("PRINT " + s[0]); for (int i = 1; i < s.length; i++) { out.println("RIGHT"); out.println("PRINT " + s[i]); } } else { while (right-- > 0) out.println("RIGHT"); out.println("PRINT " + s[s.length - 1]); for (int i = s.length - 2; i > -1; i--) { out.println("LEFT"); out.println("PRINT " + s[i]); } } br.close(); out.close(); } static BufferedReader br; static StringTokenizer sc; static PrintWriter out; static String nxtTok() throws IOException { while (!sc.hasMoreTokens()) { String s = br.readLine(); if (s == null) return null; sc = new StringTokenizer(s.trim()); } return sc.nextToken(); } static int nxtInt() throws IOException { return Integer.parseInt(nxtTok()); } static long nxtLng() throws IOException { return Long.parseLong(nxtTok()); } static double nxtDbl() throws IOException { return Double.parseDouble(nxtTok()); } static int[] nxtIntArr(int n) throws IOException { int[] a = new int[n]; for (int i = 0; i < n; i++) a[i] = nxtInt(); return a; } static long[] nxtLngArr(int n) throws IOException { long[] a = new long[n]; for (int i = 0; i < n; i++) a[i] = nxtLng(); return a; } static char[] nxtCharArr() throws IOException { return nxtTok().toCharArray(); } }
Java
["2 2\nR1", "2 1\nR1", "6 4\nGO?GO!"]
1 second
["PRINT 1\nLEFT\nPRINT R", "PRINT R\nRIGHT\nPRINT 1", "RIGHT\nRIGHT\nPRINT !\nLEFT\nPRINT O\nLEFT\nPRINT G\nLEFT\nPRINT ?\nLEFT\nPRINT O\nLEFT\nPRINT G"]
NoteNote that the ladder cannot be shifted by less than one meter. The ladder can only stand in front of some square of the poster. For example, you cannot shift a ladder by half a meter and position it between two squares. Then go up and paint the first character and the second character.
Java 7
standard input
[ "implementation", "greedy" ]
e3a03f3f01a77a1983121bab4218c39c
The first line contains two integers, n and k (1 ≤ k ≤ n ≤ 100) — the number of characters in the slogan and the initial position of the ladder, correspondingly. The next line contains the slogan as n characters written without spaces. Each character of the slogan is either a large English letter, or digit, or one of the characters: '.', '!', ',', '?'.
900
In t lines, print the actions the programmers need to make. In the i-th line print: "LEFT" (without the quotes), if the i-th action was "move the ladder to the left"; "RIGHT" (without the quotes), if the i-th action was "move the ladder to the right"; "PRINT x" (without the quotes), if the i-th action was to "go up the ladder, paint character x, go down the ladder". The painting time (variable t) must be minimum possible. If there are multiple optimal painting plans, you can print any of them.
standard output
PASSED
7f939a816652625b1a98c2dacc5bbb94
train_002.jsonl
1397837400
The R1 company has recently bought a high rise building in the centre of Moscow for its main office. It's time to decorate the new office, and the first thing to do is to write the company's slogan above the main entrance to the building.The slogan of the company consists of n characters, so the decorators hung a large banner, n meters wide and 1 meter high, divided into n equal squares. The first character of the slogan must be in the first square (the leftmost) of the poster, the second character must be in the second square, and so on.Of course, the R1 programmers want to write the slogan on the poster themselves. To do this, they have a large (and a very heavy) ladder which was put exactly opposite the k-th square of the poster. To draw the i-th character of the slogan on the poster, you need to climb the ladder, standing in front of the i-th square of the poster. This action (along with climbing up and down the ladder) takes one hour for a painter. The painter is not allowed to draw characters in the adjacent squares when the ladder is in front of the i-th square because the uncomfortable position of the ladder may make the characters untidy. Besides, the programmers can move the ladder. In one hour, they can move the ladder either a meter to the right or a meter to the left.Drawing characters and moving the ladder is very tiring, so the programmers want to finish the job in as little time as possible. Develop for them an optimal poster painting plan!
256 megabytes
import java.io.BufferedReader; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.util.StringTokenizer; public class Solver { public static void main(String[] Args) throws NumberFormatException, IOException { new Solver().Run(); } PrintWriter pw; StringTokenizer Stok; BufferedReader br; public String nextToken() throws IOException { while (Stok == null || !Stok.hasMoreTokens()) { Stok = new StringTokenizer(br.readLine()); } return Stok.nextToken(); } public int nextInt() throws NumberFormatException, IOException { return Integer.parseInt(nextToken()); } public double nextDouble() throws NumberFormatException, IOException { return Double.parseDouble(nextToken()); } public long nextLong() throws NumberFormatException, IOException { return Long.parseLong(nextToken()); } int n,pos; int mas[]; int result=0; String str; void printFront(){ for (int i=pos; i>1; i--) pw.println("LEFT"); for (int i=0; i<n-1; i++){ pw.print("PRINT "); pw.println(str.charAt(i)); pw.println("RIGHT"); } pw.print("PRINT "); pw.println(str.charAt(n-1)); } void printBack(){ for (int i=pos; i<n; i++) pw.println("RIGHT"); for (int i=n-1; i>0; i--){ pw.print("PRINT "); pw.println(str.charAt(i)); pw.println("LEFT"); } pw.print("PRINT "); pw.println(str.charAt(0)); } public void Run() throws NumberFormatException, IOException { //br = new BufferedReader(new FileReader("input.txt")); pw = new PrintWriter("output.txt"); br=new BufferedReader(new InputStreamReader(System.in)); pw=new PrintWriter(new OutputStreamWriter(System.out)); n=nextInt(); pos=nextInt(); str=br.readLine(); if (pos<=n/2) printFront(); else printBack(); pw.flush(); pw.close(); } }
Java
["2 2\nR1", "2 1\nR1", "6 4\nGO?GO!"]
1 second
["PRINT 1\nLEFT\nPRINT R", "PRINT R\nRIGHT\nPRINT 1", "RIGHT\nRIGHT\nPRINT !\nLEFT\nPRINT O\nLEFT\nPRINT G\nLEFT\nPRINT ?\nLEFT\nPRINT O\nLEFT\nPRINT G"]
NoteNote that the ladder cannot be shifted by less than one meter. The ladder can only stand in front of some square of the poster. For example, you cannot shift a ladder by half a meter and position it between two squares. Then go up and paint the first character and the second character.
Java 7
standard input
[ "implementation", "greedy" ]
e3a03f3f01a77a1983121bab4218c39c
The first line contains two integers, n and k (1 ≤ k ≤ n ≤ 100) — the number of characters in the slogan and the initial position of the ladder, correspondingly. The next line contains the slogan as n characters written without spaces. Each character of the slogan is either a large English letter, or digit, or one of the characters: '.', '!', ',', '?'.
900
In t lines, print the actions the programmers need to make. In the i-th line print: "LEFT" (without the quotes), if the i-th action was "move the ladder to the left"; "RIGHT" (without the quotes), if the i-th action was "move the ladder to the right"; "PRINT x" (without the quotes), if the i-th action was to "go up the ladder, paint character x, go down the ladder". The painting time (variable t) must be minimum possible. If there are multiple optimal painting plans, you can print any of them.
standard output
PASSED
c78fc41dceed62a81fdd0e54c1e70ba7
train_002.jsonl
1397837400
The R1 company has recently bought a high rise building in the centre of Moscow for its main office. It's time to decorate the new office, and the first thing to do is to write the company's slogan above the main entrance to the building.The slogan of the company consists of n characters, so the decorators hung a large banner, n meters wide and 1 meter high, divided into n equal squares. The first character of the slogan must be in the first square (the leftmost) of the poster, the second character must be in the second square, and so on.Of course, the R1 programmers want to write the slogan on the poster themselves. To do this, they have a large (and a very heavy) ladder which was put exactly opposite the k-th square of the poster. To draw the i-th character of the slogan on the poster, you need to climb the ladder, standing in front of the i-th square of the poster. This action (along with climbing up and down the ladder) takes one hour for a painter. The painter is not allowed to draw characters in the adjacent squares when the ladder is in front of the i-th square because the uncomfortable position of the ladder may make the characters untidy. Besides, the programmers can move the ladder. In one hour, they can move the ladder either a meter to the right or a meter to the left.Drawing characters and moving the ladder is very tiring, so the programmers want to finish the job in as little time as possible. Develop for them an optimal poster painting plan!
256 megabytes
import java.io.InputStreamReader; import java.io.IOException; import java.io.BufferedReader; import java.io.OutputStream; import java.io.PrintWriter; import java.io.Reader; import java.io.Writer; import java.util.StringTokenizer; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the top */ public class Main { public static void main(String[] args) { InputStream inputStream = System.in; OutputStream outputStream = System.out; InputReader in = new InputReader(inputStream); OutputWriter out = new OutputWriter(outputStream); TaskA solver = new TaskA(); solver.solve(1, in, out); out.close(); } } class TaskA { public void solve(int testNumber, InputReader in, OutputWriter out) { int n = in.readInt(), k = in.readInt(); char[] c = in.readWord().toCharArray(); if (k < n - k + 1){ for (int i = k; i >= 2; i--) out.printLine("LEFT"); for (int i = 1; i <= n; i++){ out.printf("PRINT %c\n", c[i - 1]); if (i != n) out.printLine("RIGHT"); } } else{ for (int i = k; i < n; i++) out.printLine("RIGHT"); for (int i = n; i >= 1; i--){ out.printf("PRINT %c\n", c[i - 1]); if (i != 1) out.printLine("LEFT"); } } } } class InputReader { private BufferedReader reader; private StringTokenizer tokenizer; public InputReader(Reader in){ reader = new BufferedReader(in); } public InputReader(InputStream stream){ reader = new BufferedReader(new InputStreamReader(stream)); } public String readLine(){ String result = null; try{ result = reader.readLine(); } catch (IOException e){ e.printStackTrace(); } return result; } public String readWord(){ while (tokenizer == null || !tokenizer.hasMoreTokens()) tokenizer = new StringTokenizer(readLine()); return tokenizer.nextToken(); } public int readInt(){ return Integer.parseInt(readWord()); } } class OutputWriter { private PrintWriter writer; public OutputWriter(Writer out){ writer = new PrintWriter(out); } public OutputWriter(OutputStream stream){ writer = new PrintWriter(stream); } public void print(Object...args){ int size = args.length; for (int i = 0; i < size; i++) writer.print(args[i]); } public void printLine(Object...args){ print(args); writer.println(); } public void printf(String format, Object...args){ writer.printf(format, args); } public void close(){ writer.close(); } }
Java
["2 2\nR1", "2 1\nR1", "6 4\nGO?GO!"]
1 second
["PRINT 1\nLEFT\nPRINT R", "PRINT R\nRIGHT\nPRINT 1", "RIGHT\nRIGHT\nPRINT !\nLEFT\nPRINT O\nLEFT\nPRINT G\nLEFT\nPRINT ?\nLEFT\nPRINT O\nLEFT\nPRINT G"]
NoteNote that the ladder cannot be shifted by less than one meter. The ladder can only stand in front of some square of the poster. For example, you cannot shift a ladder by half a meter and position it between two squares. Then go up and paint the first character and the second character.
Java 7
standard input
[ "implementation", "greedy" ]
e3a03f3f01a77a1983121bab4218c39c
The first line contains two integers, n and k (1 ≤ k ≤ n ≤ 100) — the number of characters in the slogan and the initial position of the ladder, correspondingly. The next line contains the slogan as n characters written without spaces. Each character of the slogan is either a large English letter, or digit, or one of the characters: '.', '!', ',', '?'.
900
In t lines, print the actions the programmers need to make. In the i-th line print: "LEFT" (without the quotes), if the i-th action was "move the ladder to the left"; "RIGHT" (without the quotes), if the i-th action was "move the ladder to the right"; "PRINT x" (without the quotes), if the i-th action was to "go up the ladder, paint character x, go down the ladder". The painting time (variable t) must be minimum possible. If there are multiple optimal painting plans, you can print any of them.
standard output
PASSED
039bc9f6f45bebc5e2d6b2c48160aeac
train_002.jsonl
1397837400
The R1 company has recently bought a high rise building in the centre of Moscow for its main office. It's time to decorate the new office, and the first thing to do is to write the company's slogan above the main entrance to the building.The slogan of the company consists of n characters, so the decorators hung a large banner, n meters wide and 1 meter high, divided into n equal squares. The first character of the slogan must be in the first square (the leftmost) of the poster, the second character must be in the second square, and so on.Of course, the R1 programmers want to write the slogan on the poster themselves. To do this, they have a large (and a very heavy) ladder which was put exactly opposite the k-th square of the poster. To draw the i-th character of the slogan on the poster, you need to climb the ladder, standing in front of the i-th square of the poster. This action (along with climbing up and down the ladder) takes one hour for a painter. The painter is not allowed to draw characters in the adjacent squares when the ladder is in front of the i-th square because the uncomfortable position of the ladder may make the characters untidy. Besides, the programmers can move the ladder. In one hour, they can move the ladder either a meter to the right or a meter to the left.Drawing characters and moving the ladder is very tiring, so the programmers want to finish the job in as little time as possible. Develop for them an optimal poster painting plan!
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.math.BigInteger; import java.util.ArrayList; import java.util.Scanner; import java.util.StringTokenizer; import java.util.regex.Matcher; import java.util.regex.Pattern; /** * * @author Ammar.Eliwat */ public class TEST{ public static void main(String[] args) throws IOException { Scanner input = new Scanner(System.in); // BufferedReader buffer = new BufferedReader(new InputStreamReader(System.in)); // String str; //while ((str = buffer.readLine()) != null) { int n=input.nextInt(); int start=input.nextInt(); String A=input.next(); if(start==1){ for(int i=0;i<A.length();i++){ if(i==A.length()-1){System.out.println("PRINT "+A.charAt(i));continue;} System.out.println("PRINT "+A.charAt(i)); System.out.println("RIGHT"); } } else{ if(start==A.length()){ for(int i=A.length()-1;i>=0;i--){ if(i==0){ System.out.println("PRINT "+A.charAt(i)); continue; } System.out.println("PRINT "+A.charAt(i)); System.out.println("LEFT"); } } else{ start=start-1; n=n-1; int first=Math.abs(0-start); int end=Math.abs(start-n); int min=0; if(first<=end) min=first; else min=end; if(min==end){ for(int i=0;i<min;i++) System.out.println("RIGHT"); for(int i=A.length()-1;i>=0;i--){ if(i==0){ System.out.println("PRINT "+A.charAt(i));continue;} System.out.println("PRINT "+A.charAt(i)); System.out.println("LEFT"); } } else{ for(int i=0;i<min;i++) System.out.println("LEFT"); for(int i=0;i<A.length();i++){ if(i==A.length()-1){ System.out.println("PRINT "+A.charAt(i));continue;} System.out.println("PRINT "+A.charAt(i)); System.out.println("RIGHT"); } } } } // String A=input.next(); // String B=input.next(); // Pattern p= Pattern.compile(B+"$"); // Matcher m=p.matcher(A); // if(m.find()==true) // System.out.println("yes"); // else // System.out.println("no"); // // } } }
Java
["2 2\nR1", "2 1\nR1", "6 4\nGO?GO!"]
1 second
["PRINT 1\nLEFT\nPRINT R", "PRINT R\nRIGHT\nPRINT 1", "RIGHT\nRIGHT\nPRINT !\nLEFT\nPRINT O\nLEFT\nPRINT G\nLEFT\nPRINT ?\nLEFT\nPRINT O\nLEFT\nPRINT G"]
NoteNote that the ladder cannot be shifted by less than one meter. The ladder can only stand in front of some square of the poster. For example, you cannot shift a ladder by half a meter and position it between two squares. Then go up and paint the first character and the second character.
Java 7
standard input
[ "implementation", "greedy" ]
e3a03f3f01a77a1983121bab4218c39c
The first line contains two integers, n and k (1 ≤ k ≤ n ≤ 100) — the number of characters in the slogan and the initial position of the ladder, correspondingly. The next line contains the slogan as n characters written without spaces. Each character of the slogan is either a large English letter, or digit, or one of the characters: '.', '!', ',', '?'.
900
In t lines, print the actions the programmers need to make. In the i-th line print: "LEFT" (without the quotes), if the i-th action was "move the ladder to the left"; "RIGHT" (without the quotes), if the i-th action was "move the ladder to the right"; "PRINT x" (without the quotes), if the i-th action was to "go up the ladder, paint character x, go down the ladder". The painting time (variable t) must be minimum possible. If there are multiple optimal painting plans, you can print any of them.
standard output
PASSED
7e1ffd089039efa038c5134c2b038a6b
train_002.jsonl
1397837400
The R1 company has recently bought a high rise building in the centre of Moscow for its main office. It's time to decorate the new office, and the first thing to do is to write the company's slogan above the main entrance to the building.The slogan of the company consists of n characters, so the decorators hung a large banner, n meters wide and 1 meter high, divided into n equal squares. The first character of the slogan must be in the first square (the leftmost) of the poster, the second character must be in the second square, and so on.Of course, the R1 programmers want to write the slogan on the poster themselves. To do this, they have a large (and a very heavy) ladder which was put exactly opposite the k-th square of the poster. To draw the i-th character of the slogan on the poster, you need to climb the ladder, standing in front of the i-th square of the poster. This action (along with climbing up and down the ladder) takes one hour for a painter. The painter is not allowed to draw characters in the adjacent squares when the ladder is in front of the i-th square because the uncomfortable position of the ladder may make the characters untidy. Besides, the programmers can move the ladder. In one hour, they can move the ladder either a meter to the right or a meter to the left.Drawing characters and moving the ladder is very tiring, so the programmers want to finish the job in as little time as possible. Develop for them an optimal poster painting plan!
256 megabytes
import java.io.IOException; import java.util.Scanner; public class A { public static void main(String[] args) throws IOException{ Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int k = sc.nextInt(); String s = sc.next(); if (k > n/2){ while(k!=n){ k++; System.out.println("RIGHT"); } for(int i = s.length()-1; i >=0; i-- ) { System.out.println("PRINT "+ s.charAt(i)); if (i != 0) System.out.println("LEFT"); } } else{ while(k!=1){ k--; System.out.println("LEFT"); } for(int i = 0; i < s.length(); i++ ) { System.out.println("PRINT "+ s.charAt(i)); if (i != s.length() - 1)System.out.println("RIGHT"); } } } }
Java
["2 2\nR1", "2 1\nR1", "6 4\nGO?GO!"]
1 second
["PRINT 1\nLEFT\nPRINT R", "PRINT R\nRIGHT\nPRINT 1", "RIGHT\nRIGHT\nPRINT !\nLEFT\nPRINT O\nLEFT\nPRINT G\nLEFT\nPRINT ?\nLEFT\nPRINT O\nLEFT\nPRINT G"]
NoteNote that the ladder cannot be shifted by less than one meter. The ladder can only stand in front of some square of the poster. For example, you cannot shift a ladder by half a meter and position it between two squares. Then go up and paint the first character and the second character.
Java 7
standard input
[ "implementation", "greedy" ]
e3a03f3f01a77a1983121bab4218c39c
The first line contains two integers, n and k (1 ≤ k ≤ n ≤ 100) — the number of characters in the slogan and the initial position of the ladder, correspondingly. The next line contains the slogan as n characters written without spaces. Each character of the slogan is either a large English letter, or digit, or one of the characters: '.', '!', ',', '?'.
900
In t lines, print the actions the programmers need to make. In the i-th line print: "LEFT" (without the quotes), if the i-th action was "move the ladder to the left"; "RIGHT" (without the quotes), if the i-th action was "move the ladder to the right"; "PRINT x" (without the quotes), if the i-th action was to "go up the ladder, paint character x, go down the ladder". The painting time (variable t) must be minimum possible. If there are multiple optimal painting plans, you can print any of them.
standard output
PASSED
51aeb06e276df011c117fd6b4ae5dfc7
train_002.jsonl
1397837400
The R1 company has recently bought a high rise building in the centre of Moscow for its main office. It's time to decorate the new office, and the first thing to do is to write the company's slogan above the main entrance to the building.The slogan of the company consists of n characters, so the decorators hung a large banner, n meters wide and 1 meter high, divided into n equal squares. The first character of the slogan must be in the first square (the leftmost) of the poster, the second character must be in the second square, and so on.Of course, the R1 programmers want to write the slogan on the poster themselves. To do this, they have a large (and a very heavy) ladder which was put exactly opposite the k-th square of the poster. To draw the i-th character of the slogan on the poster, you need to climb the ladder, standing in front of the i-th square of the poster. This action (along with climbing up and down the ladder) takes one hour for a painter. The painter is not allowed to draw characters in the adjacent squares when the ladder is in front of the i-th square because the uncomfortable position of the ladder may make the characters untidy. Besides, the programmers can move the ladder. In one hour, they can move the ladder either a meter to the right or a meter to the left.Drawing characters and moving the ladder is very tiring, so the programmers want to finish the job in as little time as possible. Develop for them an optimal poster painting plan!
256 megabytes
import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.util.Scanner; public class MyClass { public static void main(String[] args) { try (Scanner sc = new Scanner(System.in); PrintWriter pw = new PrintWriter(new OutputStreamWriter(System.out))) { int n = sc.nextInt(); int k = sc.nextInt(); String str = sc.next(); int lengthStr = str.length(); String left = "LEFT"; String right = "RIGHT"; String print = "PRINT"; double midl = (double)n / 2; if (k > midl) { if (k != n) { for (int i = 0; i < (n - k); i++) { pw.println(right); } for(int i = lengthStr-1; i >0 ; i--){ pw.println(print + " " + str.charAt(i)); pw.println(left); } pw.println(print + " " + str.charAt(0)); }else{ for(int i = lengthStr-1; i >0 ; i--){ pw.println(print + " " + str.charAt(i)); pw.println(left); } pw.println(print + " " + str.charAt(0)); } }else{ if(k != 1){ for (int i = 0; i < (k -1); i++) { pw.println(left); } for(int i = 0; i < lengthStr - 1; i++){ pw.println(print + " " + str.charAt(i)); pw.println(right); } pw.println(print + " " + str.charAt(lengthStr - 1)); }else{ for(int i = 0; i < lengthStr - 1; i++){ pw.println(print + " " + str.charAt(i)); pw.println(right); } pw.println(print + " " + str.charAt(lengthStr - 1)); } } } } }
Java
["2 2\nR1", "2 1\nR1", "6 4\nGO?GO!"]
1 second
["PRINT 1\nLEFT\nPRINT R", "PRINT R\nRIGHT\nPRINT 1", "RIGHT\nRIGHT\nPRINT !\nLEFT\nPRINT O\nLEFT\nPRINT G\nLEFT\nPRINT ?\nLEFT\nPRINT O\nLEFT\nPRINT G"]
NoteNote that the ladder cannot be shifted by less than one meter. The ladder can only stand in front of some square of the poster. For example, you cannot shift a ladder by half a meter and position it between two squares. Then go up and paint the first character and the second character.
Java 7
standard input
[ "implementation", "greedy" ]
e3a03f3f01a77a1983121bab4218c39c
The first line contains two integers, n and k (1 ≤ k ≤ n ≤ 100) — the number of characters in the slogan and the initial position of the ladder, correspondingly. The next line contains the slogan as n characters written without spaces. Each character of the slogan is either a large English letter, or digit, or one of the characters: '.', '!', ',', '?'.
900
In t lines, print the actions the programmers need to make. In the i-th line print: "LEFT" (without the quotes), if the i-th action was "move the ladder to the left"; "RIGHT" (without the quotes), if the i-th action was "move the ladder to the right"; "PRINT x" (without the quotes), if the i-th action was to "go up the ladder, paint character x, go down the ladder". The painting time (variable t) must be minimum possible. If there are multiple optimal painting plans, you can print any of them.
standard output
PASSED
d037bce7849f1bb1acd203f0c5046225
train_002.jsonl
1397837400
The R1 company has recently bought a high rise building in the centre of Moscow for its main office. It's time to decorate the new office, and the first thing to do is to write the company's slogan above the main entrance to the building.The slogan of the company consists of n characters, so the decorators hung a large banner, n meters wide and 1 meter high, divided into n equal squares. The first character of the slogan must be in the first square (the leftmost) of the poster, the second character must be in the second square, and so on.Of course, the R1 programmers want to write the slogan on the poster themselves. To do this, they have a large (and a very heavy) ladder which was put exactly opposite the k-th square of the poster. To draw the i-th character of the slogan on the poster, you need to climb the ladder, standing in front of the i-th square of the poster. This action (along with climbing up and down the ladder) takes one hour for a painter. The painter is not allowed to draw characters in the adjacent squares when the ladder is in front of the i-th square because the uncomfortable position of the ladder may make the characters untidy. Besides, the programmers can move the ladder. In one hour, they can move the ladder either a meter to the right or a meter to the left.Drawing characters and moving the ladder is very tiring, so the programmers want to finish the job in as little time as possible. Develop for them an optimal poster painting plan!
256 megabytes
import java.util.*; import java.io.*; public class CS2014R1A { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); int k = in.nextInt(); String s = in.nextLine(); s = in.nextLine(); if(k > n/2) { for (int i = 1; i < n-k+1; i++) { System.out.println("RIGHT"); } for (int i = (s.length()-1); i >= 0; i--) { System.out.println("PRINT " + s.charAt(i)); if (i != 0) System.out.println("LEFT"); } } else { for (int i = 0; i < k-1; i++) { System.out.println("LEFT"); } for (int i = 0; i < s.length(); i++) { System.out.println("PRINT " + s.charAt(i)); if (i != s.length()-1) System.out.println("RIGHT"); } } } }
Java
["2 2\nR1", "2 1\nR1", "6 4\nGO?GO!"]
1 second
["PRINT 1\nLEFT\nPRINT R", "PRINT R\nRIGHT\nPRINT 1", "RIGHT\nRIGHT\nPRINT !\nLEFT\nPRINT O\nLEFT\nPRINT G\nLEFT\nPRINT ?\nLEFT\nPRINT O\nLEFT\nPRINT G"]
NoteNote that the ladder cannot be shifted by less than one meter. The ladder can only stand in front of some square of the poster. For example, you cannot shift a ladder by half a meter and position it between two squares. Then go up and paint the first character and the second character.
Java 7
standard input
[ "implementation", "greedy" ]
e3a03f3f01a77a1983121bab4218c39c
The first line contains two integers, n and k (1 ≤ k ≤ n ≤ 100) — the number of characters in the slogan and the initial position of the ladder, correspondingly. The next line contains the slogan as n characters written without spaces. Each character of the slogan is either a large English letter, or digit, or one of the characters: '.', '!', ',', '?'.
900
In t lines, print the actions the programmers need to make. In the i-th line print: "LEFT" (without the quotes), if the i-th action was "move the ladder to the left"; "RIGHT" (without the quotes), if the i-th action was "move the ladder to the right"; "PRINT x" (without the quotes), if the i-th action was to "go up the ladder, paint character x, go down the ladder". The painting time (variable t) must be minimum possible. If there are multiple optimal painting plans, you can print any of them.
standard output
PASSED
f23da652387b3df1fe3f39aa8c09bc9c
train_002.jsonl
1397837400
The R1 company has recently bought a high rise building in the centre of Moscow for its main office. It's time to decorate the new office, and the first thing to do is to write the company's slogan above the main entrance to the building.The slogan of the company consists of n characters, so the decorators hung a large banner, n meters wide and 1 meter high, divided into n equal squares. The first character of the slogan must be in the first square (the leftmost) of the poster, the second character must be in the second square, and so on.Of course, the R1 programmers want to write the slogan on the poster themselves. To do this, they have a large (and a very heavy) ladder which was put exactly opposite the k-th square of the poster. To draw the i-th character of the slogan on the poster, you need to climb the ladder, standing in front of the i-th square of the poster. This action (along with climbing up and down the ladder) takes one hour for a painter. The painter is not allowed to draw characters in the adjacent squares when the ladder is in front of the i-th square because the uncomfortable position of the ladder may make the characters untidy. Besides, the programmers can move the ladder. In one hour, they can move the ladder either a meter to the right or a meter to the left.Drawing characters and moving the ladder is very tiring, so the programmers want to finish the job in as little time as possible. Develop for them an optimal poster painting plan!
256 megabytes
import java.io.*; import java.util.*; public class Main implements Runnable { public void _main() throws IOException { int n = nextInt(); int k = nextInt() - 1; char[] s = next().toCharArray(); if (k < n / 2) { for (int i = 0; i < k; i++) { out.println("LEFT"); } for (int i = 0; i < n; i++) { out.println("PRINT " + s[i]); if (i < n - 1) { out.println("RIGHT"); } } } else { for (int i = 0; i < n - 1 - k; i++) { out.println("RIGHT"); } for (int i = 0; i < n; i++) { out.println("PRINT " + s[n - i - 1]); if (i < n - 1) { out.println("LEFT"); } } } } private BufferedReader in; private PrintWriter out; private StringTokenizer st; private String next() throws IOException { while (st == null || !st.hasMoreTokens()) { String rl = in.readLine(); if (rl == null) return null; st = new StringTokenizer(rl); } return st.nextToken(); } private int nextInt() throws IOException { return Integer.parseInt(next()); } private long nextLong() throws IOException { return Long.parseLong(next()); } private double nextDouble() throws IOException { return Double.parseDouble(next()); } public static void main(String[] args) { Locale.setDefault(Locale.UK); new Thread(new Main()).start(); } public void run() { try { in = new BufferedReader(new InputStreamReader(System.in)); out = new PrintWriter(System.out); //in = new BufferedReader(new FileReader("a.in")); //out = new PrintWriter(new FileWriter("a.out")); _main(); out.close(); } catch (Exception e) { e.printStackTrace(); System.exit(202); } } }
Java
["2 2\nR1", "2 1\nR1", "6 4\nGO?GO!"]
1 second
["PRINT 1\nLEFT\nPRINT R", "PRINT R\nRIGHT\nPRINT 1", "RIGHT\nRIGHT\nPRINT !\nLEFT\nPRINT O\nLEFT\nPRINT G\nLEFT\nPRINT ?\nLEFT\nPRINT O\nLEFT\nPRINT G"]
NoteNote that the ladder cannot be shifted by less than one meter. The ladder can only stand in front of some square of the poster. For example, you cannot shift a ladder by half a meter and position it between two squares. Then go up and paint the first character and the second character.
Java 7
standard input
[ "implementation", "greedy" ]
e3a03f3f01a77a1983121bab4218c39c
The first line contains two integers, n and k (1 ≤ k ≤ n ≤ 100) — the number of characters in the slogan and the initial position of the ladder, correspondingly. The next line contains the slogan as n characters written without spaces. Each character of the slogan is either a large English letter, or digit, or one of the characters: '.', '!', ',', '?'.
900
In t lines, print the actions the programmers need to make. In the i-th line print: "LEFT" (without the quotes), if the i-th action was "move the ladder to the left"; "RIGHT" (without the quotes), if the i-th action was "move the ladder to the right"; "PRINT x" (without the quotes), if the i-th action was to "go up the ladder, paint character x, go down the ladder". The painting time (variable t) must be minimum possible. If there are multiple optimal painting plans, you can print any of them.
standard output
PASSED
ea9628bb9e38b80b867df39e91469272
train_002.jsonl
1397837400
The R1 company has recently bought a high rise building in the centre of Moscow for its main office. It's time to decorate the new office, and the first thing to do is to write the company's slogan above the main entrance to the building.The slogan of the company consists of n characters, so the decorators hung a large banner, n meters wide and 1 meter high, divided into n equal squares. The first character of the slogan must be in the first square (the leftmost) of the poster, the second character must be in the second square, and so on.Of course, the R1 programmers want to write the slogan on the poster themselves. To do this, they have a large (and a very heavy) ladder which was put exactly opposite the k-th square of the poster. To draw the i-th character of the slogan on the poster, you need to climb the ladder, standing in front of the i-th square of the poster. This action (along with climbing up and down the ladder) takes one hour for a painter. The painter is not allowed to draw characters in the adjacent squares when the ladder is in front of the i-th square because the uncomfortable position of the ladder may make the characters untidy. Besides, the programmers can move the ladder. In one hour, they can move the ladder either a meter to the right or a meter to the left.Drawing characters and moving the ladder is very tiring, so the programmers want to finish the job in as little time as possible. Develop for them an optimal poster painting plan!
256 megabytes
import java.io.*; import java.util.*; public class Main implements Runnable { final boolean isFileIO = false; BufferedReader in; PrintWriter out; StringTokenizer st = new StringTokenizer(""); String delim = " "; public static void main(String[] args) { new Thread(null, new Main(), "", 268435456).start(); } public void run() { try { initIO(); solve(); out.close(); } catch(Exception e) { e.printStackTrace(System.err); System.exit(-1); } } public void initIO() throws IOException { if(!isFileIO) { in = new BufferedReader(new InputStreamReader(System.in)); out = new PrintWriter(System.out); } else { in = new BufferedReader(new FileReader("input.txt")); out = new PrintWriter("output.txt"); } } String nextToken() throws IOException { if(!st.hasMoreTokens()) { st = new StringTokenizer(in.readLine()); } return st.nextToken(delim); } String readLine() throws IOException { return in.readLine(); } int nextInt() throws IOException { return Integer.parseInt(nextToken()); } long nextLong() throws IOException { return Long.parseLong(nextToken()); } double nextDouble() throws IOException { return Double.parseDouble(nextToken()); } void solve() throws IOException { int n, k; n = nextInt(); k = nextInt(); String s = readLine(); int cur = 0; if(k - 1 >= n - k) { cur = 1; } else { cur = -1; } int pos = k; while(pos != 1 && pos != n) { if(cur == -1) out.println("LEFT"); else out.println("RIGHT"); pos += cur; } cur *= -1; while(pos != 0 && pos != n + 1) { out.println("PRINT " + s.charAt(pos - 1)); pos += cur; if(cur == -1) { if(pos != 0) out.println("LEFT"); } else if(pos != n + 1) { out.println("RIGHT"); } } } }
Java
["2 2\nR1", "2 1\nR1", "6 4\nGO?GO!"]
1 second
["PRINT 1\nLEFT\nPRINT R", "PRINT R\nRIGHT\nPRINT 1", "RIGHT\nRIGHT\nPRINT !\nLEFT\nPRINT O\nLEFT\nPRINT G\nLEFT\nPRINT ?\nLEFT\nPRINT O\nLEFT\nPRINT G"]
NoteNote that the ladder cannot be shifted by less than one meter. The ladder can only stand in front of some square of the poster. For example, you cannot shift a ladder by half a meter and position it between two squares. Then go up and paint the first character and the second character.
Java 7
standard input
[ "implementation", "greedy" ]
e3a03f3f01a77a1983121bab4218c39c
The first line contains two integers, n and k (1 ≤ k ≤ n ≤ 100) — the number of characters in the slogan and the initial position of the ladder, correspondingly. The next line contains the slogan as n characters written without spaces. Each character of the slogan is either a large English letter, or digit, or one of the characters: '.', '!', ',', '?'.
900
In t lines, print the actions the programmers need to make. In the i-th line print: "LEFT" (without the quotes), if the i-th action was "move the ladder to the left"; "RIGHT" (without the quotes), if the i-th action was "move the ladder to the right"; "PRINT x" (without the quotes), if the i-th action was to "go up the ladder, paint character x, go down the ladder". The painting time (variable t) must be minimum possible. If there are multiple optimal painting plans, you can print any of them.
standard output
PASSED
413b188357b55dd24a673c62785831ad
train_002.jsonl
1397837400
The R1 company has recently bought a high rise building in the centre of Moscow for its main office. It's time to decorate the new office, and the first thing to do is to write the company's slogan above the main entrance to the building.The slogan of the company consists of n characters, so the decorators hung a large banner, n meters wide and 1 meter high, divided into n equal squares. The first character of the slogan must be in the first square (the leftmost) of the poster, the second character must be in the second square, and so on.Of course, the R1 programmers want to write the slogan on the poster themselves. To do this, they have a large (and a very heavy) ladder which was put exactly opposite the k-th square of the poster. To draw the i-th character of the slogan on the poster, you need to climb the ladder, standing in front of the i-th square of the poster. This action (along with climbing up and down the ladder) takes one hour for a painter. The painter is not allowed to draw characters in the adjacent squares when the ladder is in front of the i-th square because the uncomfortable position of the ladder may make the characters untidy. Besides, the programmers can move the ladder. In one hour, they can move the ladder either a meter to the right or a meter to the left.Drawing characters and moving the ladder is very tiring, so the programmers want to finish the job in as little time as possible. Develop for them an optimal poster painting plan!
256 megabytes
//package codestrike.r1; import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Arrays; import java.util.InputMismatchException; public class A { InputStream is; PrintWriter out; String INPUT = ""; void solve() { int n = ni(), K = ni(); char[] s = ns().toCharArray(); if(K-1 < n-K){ for(int i = K-1;i >= 1;i--){ out.println("LEFT"); } for(int i = 0;i < s.length;i++){ out.println("PRINT " + s[i]); if(i < s.length-1)out.println("RIGHT"); } }else{ for(int i = K+1;i <= n;i++){ out.println("RIGHT"); } for(int i = s.length-1;i >= 0;i--){ out.println("PRINT " + s[i]); if(i > 0)out.println("LEFT"); } } } void run() throws Exception { is = oj ? System.in : new ByteArrayInputStream(INPUT.getBytes()); out = new PrintWriter(System.out); long s = System.currentTimeMillis(); solve(); out.flush(); tr(System.currentTimeMillis()-s+"ms"); } public static void main(String[] args) throws Exception { new A().run(); } private byte[] inbuf = new byte[1024]; private int lenbuf = 0, ptrbuf = 0; private int readByte() { if(lenbuf == -1)throw new InputMismatchException(); if(ptrbuf >= lenbuf){ ptrbuf = 0; try { lenbuf = is.read(inbuf); } catch (IOException e) { throw new InputMismatchException(); } if(lenbuf <= 0)return -1; } return inbuf[ptrbuf++]; } private boolean isSpaceChar(int c) { return !(c >= 33 && c <= 126); } private int skip() { int b; while((b = readByte()) != -1 && isSpaceChar(b)); return b; } private double nd() { return Double.parseDouble(ns()); } private char nc() { return (char)skip(); } private String ns() { int b = skip(); StringBuilder sb = new StringBuilder(); while(!(isSpaceChar(b))){ // when nextLine, (isSpaceChar(b) && b != ' ') sb.appendCodePoint(b); b = readByte(); } return sb.toString(); } private char[] ns(int n) { char[] buf = new char[n]; int b = skip(), p = 0; while(p < n && !(isSpaceChar(b))){ buf[p++] = (char)b; b = readByte(); } return n == p ? buf : Arrays.copyOf(buf, p); } private char[][] nm(int n, int m) { char[][] map = new char[n][]; for(int i = 0;i < n;i++)map[i] = ns(m); return map; } private int[] na(int n) { int[] a = new int[n]; for(int i = 0;i < n;i++)a[i] = ni(); return a; } private int ni() { int num = 0, b; boolean minus = false; while((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-')); if(b == '-'){ minus = true; b = readByte(); } while(true){ if(b >= '0' && b <= '9'){ num = num * 10 + (b - '0'); }else{ return minus ? -num : num; } b = readByte(); } } private long nl() { long num = 0; int b; boolean minus = false; while((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-')); if(b == '-'){ minus = true; b = readByte(); } while(true){ if(b >= '0' && b <= '9'){ num = num * 10 + (b - '0'); }else{ return minus ? -num : num; } b = readByte(); } } private boolean oj = System.getProperty("ONLINE_JUDGE") != null; private void tr(Object... o) { if(!oj)System.out.println(Arrays.deepToString(o)); } }
Java
["2 2\nR1", "2 1\nR1", "6 4\nGO?GO!"]
1 second
["PRINT 1\nLEFT\nPRINT R", "PRINT R\nRIGHT\nPRINT 1", "RIGHT\nRIGHT\nPRINT !\nLEFT\nPRINT O\nLEFT\nPRINT G\nLEFT\nPRINT ?\nLEFT\nPRINT O\nLEFT\nPRINT G"]
NoteNote that the ladder cannot be shifted by less than one meter. The ladder can only stand in front of some square of the poster. For example, you cannot shift a ladder by half a meter and position it between two squares. Then go up and paint the first character and the second character.
Java 7
standard input
[ "implementation", "greedy" ]
e3a03f3f01a77a1983121bab4218c39c
The first line contains two integers, n and k (1 ≤ k ≤ n ≤ 100) — the number of characters in the slogan and the initial position of the ladder, correspondingly. The next line contains the slogan as n characters written without spaces. Each character of the slogan is either a large English letter, or digit, or one of the characters: '.', '!', ',', '?'.
900
In t lines, print the actions the programmers need to make. In the i-th line print: "LEFT" (without the quotes), if the i-th action was "move the ladder to the left"; "RIGHT" (without the quotes), if the i-th action was "move the ladder to the right"; "PRINT x" (without the quotes), if the i-th action was to "go up the ladder, paint character x, go down the ladder". The painting time (variable t) must be minimum possible. If there are multiple optimal painting plans, you can print any of them.
standard output
PASSED
82018741feb9cab55dfa891747ff1991
train_002.jsonl
1397837400
The R1 company has recently bought a high rise building in the centre of Moscow for its main office. It's time to decorate the new office, and the first thing to do is to write the company's slogan above the main entrance to the building.The slogan of the company consists of n characters, so the decorators hung a large banner, n meters wide and 1 meter high, divided into n equal squares. The first character of the slogan must be in the first square (the leftmost) of the poster, the second character must be in the second square, and so on.Of course, the R1 programmers want to write the slogan on the poster themselves. To do this, they have a large (and a very heavy) ladder which was put exactly opposite the k-th square of the poster. To draw the i-th character of the slogan on the poster, you need to climb the ladder, standing in front of the i-th square of the poster. This action (along with climbing up and down the ladder) takes one hour for a painter. The painter is not allowed to draw characters in the adjacent squares when the ladder is in front of the i-th square because the uncomfortable position of the ladder may make the characters untidy. Besides, the programmers can move the ladder. In one hour, they can move the ladder either a meter to the right or a meter to the left.Drawing characters and moving the ladder is very tiring, so the programmers want to finish the job in as little time as possible. Develop for them an optimal poster painting plan!
256 megabytes
import java.io.*; import java.util.*; import java.math.*; public class Main { BufferedReader reader; StringTokenizer tokenizer; PrintWriter out; public static void main(String[] args) { new Main().run(); } public void run() { try { reader = new BufferedReader(new InputStreamReader(System.in)); out = new PrintWriter(System.out); solver(); out.flush(); out.close(); } catch (IOException e) { e.printStackTrace(); System.exit(1); } } public void solver() throws IOException { int n = nextInt(); int k = nextInt(); String s = next(); while (true) { if (k == 1 || k == s.length()) { break; } int left = k - 1; int right = s.length() - k; if (left < right) { out.println("LEFT"); k--; } else { out.println("RIGHT"); k++; } } if (k == 1) { for (int i = 0; i < s.length(); i++) { out.println("PRINT " + s.charAt(i)); if (i + 1 < s.length()) { out.println("RIGHT"); } } } else { for (int i = s.length() - 1; i >= 0; i--) { out.println("PRINT " + s.charAt(i)); if (i - 1 >= 0) { out.println("LEFT"); } } } } String next() throws IOException { while (tokenizer == null || !tokenizer.hasMoreTokens()) { tokenizer = new StringTokenizer(reader.readLine()); } return tokenizer.nextToken(); } int nextInt() throws IOException { return Integer.parseInt(next()); } double nextDouble() throws IOException { return Double.parseDouble(next()); } long nextLong() throws IOException { return Long.parseLong(next()); } }
Java
["2 2\nR1", "2 1\nR1", "6 4\nGO?GO!"]
1 second
["PRINT 1\nLEFT\nPRINT R", "PRINT R\nRIGHT\nPRINT 1", "RIGHT\nRIGHT\nPRINT !\nLEFT\nPRINT O\nLEFT\nPRINT G\nLEFT\nPRINT ?\nLEFT\nPRINT O\nLEFT\nPRINT G"]
NoteNote that the ladder cannot be shifted by less than one meter. The ladder can only stand in front of some square of the poster. For example, you cannot shift a ladder by half a meter and position it between two squares. Then go up and paint the first character and the second character.
Java 7
standard input
[ "implementation", "greedy" ]
e3a03f3f01a77a1983121bab4218c39c
The first line contains two integers, n and k (1 ≤ k ≤ n ≤ 100) — the number of characters in the slogan and the initial position of the ladder, correspondingly. The next line contains the slogan as n characters written without spaces. Each character of the slogan is either a large English letter, or digit, or one of the characters: '.', '!', ',', '?'.
900
In t lines, print the actions the programmers need to make. In the i-th line print: "LEFT" (without the quotes), if the i-th action was "move the ladder to the left"; "RIGHT" (without the quotes), if the i-th action was "move the ladder to the right"; "PRINT x" (without the quotes), if the i-th action was to "go up the ladder, paint character x, go down the ladder". The painting time (variable t) must be minimum possible. If there are multiple optimal painting plans, you can print any of them.
standard output
PASSED
cfff75a0faad00ed62be92b3d59de70e
train_002.jsonl
1397837400
The R1 company has recently bought a high rise building in the centre of Moscow for its main office. It's time to decorate the new office, and the first thing to do is to write the company's slogan above the main entrance to the building.The slogan of the company consists of n characters, so the decorators hung a large banner, n meters wide and 1 meter high, divided into n equal squares. The first character of the slogan must be in the first square (the leftmost) of the poster, the second character must be in the second square, and so on.Of course, the R1 programmers want to write the slogan on the poster themselves. To do this, they have a large (and a very heavy) ladder which was put exactly opposite the k-th square of the poster. To draw the i-th character of the slogan on the poster, you need to climb the ladder, standing in front of the i-th square of the poster. This action (along with climbing up and down the ladder) takes one hour for a painter. The painter is not allowed to draw characters in the adjacent squares when the ladder is in front of the i-th square because the uncomfortable position of the ladder may make the characters untidy. Besides, the programmers can move the ladder. In one hour, they can move the ladder either a meter to the right or a meter to the left.Drawing characters and moving the ladder is very tiring, so the programmers want to finish the job in as little time as possible. Develop for them an optimal poster painting plan!
256 megabytes
import java.util.Scanner; public class PA { public static void main(String[] args){ Scanner in = new Scanner(System.in); int n=in.nextInt(); int init=in.nextInt(); String s = in.next(); if(init>n/2){ while(init<n){ init++; System.out.println("RIGHT"); } } else { while(init>1){ init--; System.out.println("LEFT"); } } if(init==1){ for(int i=1;i<n;i++){ System.out.printf("PRINT %c\n", s.charAt(i-1)); System.out.printf("RIGHT\n"); } System.out.printf("PRINT %c\n", s.charAt(n-1)); }else{ for(int i=n;i>1;i--){ System.out.printf("PRINT %c\n", s.charAt(i-1)); System.out.printf("LEFT\n"); } System.out.printf("PRINT %c\n", s.charAt(0)); } } }
Java
["2 2\nR1", "2 1\nR1", "6 4\nGO?GO!"]
1 second
["PRINT 1\nLEFT\nPRINT R", "PRINT R\nRIGHT\nPRINT 1", "RIGHT\nRIGHT\nPRINT !\nLEFT\nPRINT O\nLEFT\nPRINT G\nLEFT\nPRINT ?\nLEFT\nPRINT O\nLEFT\nPRINT G"]
NoteNote that the ladder cannot be shifted by less than one meter. The ladder can only stand in front of some square of the poster. For example, you cannot shift a ladder by half a meter and position it between two squares. Then go up and paint the first character and the second character.
Java 7
standard input
[ "implementation", "greedy" ]
e3a03f3f01a77a1983121bab4218c39c
The first line contains two integers, n and k (1 ≤ k ≤ n ≤ 100) — the number of characters in the slogan and the initial position of the ladder, correspondingly. The next line contains the slogan as n characters written without spaces. Each character of the slogan is either a large English letter, or digit, or one of the characters: '.', '!', ',', '?'.
900
In t lines, print the actions the programmers need to make. In the i-th line print: "LEFT" (without the quotes), if the i-th action was "move the ladder to the left"; "RIGHT" (without the quotes), if the i-th action was "move the ladder to the right"; "PRINT x" (without the quotes), if the i-th action was to "go up the ladder, paint character x, go down the ladder". The painting time (variable t) must be minimum possible. If there are multiple optimal painting plans, you can print any of them.
standard output
PASSED
28e1c5e458ed8ef0ec884ba8668790e2
train_002.jsonl
1397837400
The R1 company has recently bought a high rise building in the centre of Moscow for its main office. It's time to decorate the new office, and the first thing to do is to write the company's slogan above the main entrance to the building.The slogan of the company consists of n characters, so the decorators hung a large banner, n meters wide and 1 meter high, divided into n equal squares. The first character of the slogan must be in the first square (the leftmost) of the poster, the second character must be in the second square, and so on.Of course, the R1 programmers want to write the slogan on the poster themselves. To do this, they have a large (and a very heavy) ladder which was put exactly opposite the k-th square of the poster. To draw the i-th character of the slogan on the poster, you need to climb the ladder, standing in front of the i-th square of the poster. This action (along with climbing up and down the ladder) takes one hour for a painter. The painter is not allowed to draw characters in the adjacent squares when the ladder is in front of the i-th square because the uncomfortable position of the ladder may make the characters untidy. Besides, the programmers can move the ladder. In one hour, they can move the ladder either a meter to the right or a meter to the left.Drawing characters and moving the ladder is very tiring, so the programmers want to finish the job in as little time as possible. Develop for them an optimal poster painting plan!
256 megabytes
import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; import java.io.FileReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.Random; import javax.print.attribute.standard.Sides; public class Main { public static void main(String[] args) throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); PrintWriter out = new PrintWriter(System.out); String [] sp = br.readLine().split(" "); int n = Integer.parseInt(sp[0]); int k = Integer.parseInt(sp[1]); char [] c = br.readLine().toCharArray(); if((n - k) < k -1){ for (int i = k; i < n; i++) { out.println("RIGHT"); } for (int i = 0; i < n - 1; i++) { out.println("PRINT " + c[n - 1 - i]); out.println("LEFT"); } out.println("PRINT " + c[0]); }else{ for (int i = 0; i < k - 1; i++) { out.println("LEFT"); } for (int i = 0; i < n - 1; i++) { out.println("PRINT " + c[i]); out.println("RIGHT"); } out.println("PRINT " + c[ n - 1]); } br.close(); out.close(); } }
Java
["2 2\nR1", "2 1\nR1", "6 4\nGO?GO!"]
1 second
["PRINT 1\nLEFT\nPRINT R", "PRINT R\nRIGHT\nPRINT 1", "RIGHT\nRIGHT\nPRINT !\nLEFT\nPRINT O\nLEFT\nPRINT G\nLEFT\nPRINT ?\nLEFT\nPRINT O\nLEFT\nPRINT G"]
NoteNote that the ladder cannot be shifted by less than one meter. The ladder can only stand in front of some square of the poster. For example, you cannot shift a ladder by half a meter and position it between two squares. Then go up and paint the first character and the second character.
Java 7
standard input
[ "implementation", "greedy" ]
e3a03f3f01a77a1983121bab4218c39c
The first line contains two integers, n and k (1 ≤ k ≤ n ≤ 100) — the number of characters in the slogan and the initial position of the ladder, correspondingly. The next line contains the slogan as n characters written without spaces. Each character of the slogan is either a large English letter, or digit, or one of the characters: '.', '!', ',', '?'.
900
In t lines, print the actions the programmers need to make. In the i-th line print: "LEFT" (without the quotes), if the i-th action was "move the ladder to the left"; "RIGHT" (without the quotes), if the i-th action was "move the ladder to the right"; "PRINT x" (without the quotes), if the i-th action was to "go up the ladder, paint character x, go down the ladder". The painting time (variable t) must be minimum possible. If there are multiple optimal painting plans, you can print any of them.
standard output
PASSED
3b1de6b1eb636512da893c47e504883a
train_002.jsonl
1397837400
The R1 company has recently bought a high rise building in the centre of Moscow for its main office. It's time to decorate the new office, and the first thing to do is to write the company's slogan above the main entrance to the building.The slogan of the company consists of n characters, so the decorators hung a large banner, n meters wide and 1 meter high, divided into n equal squares. The first character of the slogan must be in the first square (the leftmost) of the poster, the second character must be in the second square, and so on.Of course, the R1 programmers want to write the slogan on the poster themselves. To do this, they have a large (and a very heavy) ladder which was put exactly opposite the k-th square of the poster. To draw the i-th character of the slogan on the poster, you need to climb the ladder, standing in front of the i-th square of the poster. This action (along with climbing up and down the ladder) takes one hour for a painter. The painter is not allowed to draw characters in the adjacent squares when the ladder is in front of the i-th square because the uncomfortable position of the ladder may make the characters untidy. Besides, the programmers can move the ladder. In one hour, they can move the ladder either a meter to the right or a meter to the left.Drawing characters and moving the ladder is very tiring, so the programmers want to finish the job in as little time as possible. Develop for them an optimal poster painting plan!
256 megabytes
//package main; import java.util.*; import java.io.*; import java.math.BigInteger; public class Main { FastScanner scan; PrintWriter out; BufferedReader in; static boolean isEnd(String a, String s) { return a.equals(s); } public void solve() throws Exception { int n = scan.nextInt(), k = scan.nextInt(); String s = scan.next(); char[] ch = s.toCharArray(); if(k>n-k) { for (int i=k-1; i<n-1; i++) { out.println("RIGHT"); } for(int i=n-1;i>=0; i--) { out.println("PRINT "+ch[i]); if(i-1>=0) { out.println("LEFT"); } } } else { for (int i=k-1; i>0; i--) { out.println("LEFT"); } for(int i=0;i<n; i++) { out.println("PRINT "+ch[i]); if(i+1<n) { out.println("RIGHT"); } } } } static Throwable uncaught; public void run() { try { in = new BufferedReader(new InputStreamReader(System.in)); out = new PrintWriter(System.out); scan = new FastScanner(in); solve(); } catch (Throwable uncaught) { Main.uncaught = uncaught; } finally { out.close(); } } class FastScanner { BufferedReader in; StringTokenizer st; FastScanner(BufferedReader in) { this.in = in; } String next() throws IOException { while (st == null || !st.hasMoreTokens()) { st = new StringTokenizer(in.readLine()); } return st.nextToken(); } public long nextLong() throws Exception { return Long.parseLong(next()); } public double nextDouble() throws Exception { return Double.parseDouble(next()); } int nextInt() throws IOException { return Integer.parseInt(next()); } BigInteger nextBig() throws IOException { return new BigInteger(next()); } } public static void main(String[] arg) { new Main().run(); } }
Java
["2 2\nR1", "2 1\nR1", "6 4\nGO?GO!"]
1 second
["PRINT 1\nLEFT\nPRINT R", "PRINT R\nRIGHT\nPRINT 1", "RIGHT\nRIGHT\nPRINT !\nLEFT\nPRINT O\nLEFT\nPRINT G\nLEFT\nPRINT ?\nLEFT\nPRINT O\nLEFT\nPRINT G"]
NoteNote that the ladder cannot be shifted by less than one meter. The ladder can only stand in front of some square of the poster. For example, you cannot shift a ladder by half a meter and position it between two squares. Then go up and paint the first character and the second character.
Java 7
standard input
[ "implementation", "greedy" ]
e3a03f3f01a77a1983121bab4218c39c
The first line contains two integers, n and k (1 ≤ k ≤ n ≤ 100) — the number of characters in the slogan and the initial position of the ladder, correspondingly. The next line contains the slogan as n characters written without spaces. Each character of the slogan is either a large English letter, or digit, or one of the characters: '.', '!', ',', '?'.
900
In t lines, print the actions the programmers need to make. In the i-th line print: "LEFT" (without the quotes), if the i-th action was "move the ladder to the left"; "RIGHT" (without the quotes), if the i-th action was "move the ladder to the right"; "PRINT x" (without the quotes), if the i-th action was to "go up the ladder, paint character x, go down the ladder". The painting time (variable t) must be minimum possible. If there are multiple optimal painting plans, you can print any of them.
standard output
PASSED
5e683c85884dc4390f207d78e0caf8e2
train_002.jsonl
1397837400
The R1 company has recently bought a high rise building in the centre of Moscow for its main office. It's time to decorate the new office, and the first thing to do is to write the company's slogan above the main entrance to the building.The slogan of the company consists of n characters, so the decorators hung a large banner, n meters wide and 1 meter high, divided into n equal squares. The first character of the slogan must be in the first square (the leftmost) of the poster, the second character must be in the second square, and so on.Of course, the R1 programmers want to write the slogan on the poster themselves. To do this, they have a large (and a very heavy) ladder which was put exactly opposite the k-th square of the poster. To draw the i-th character of the slogan on the poster, you need to climb the ladder, standing in front of the i-th square of the poster. This action (along with climbing up and down the ladder) takes one hour for a painter. The painter is not allowed to draw characters in the adjacent squares when the ladder is in front of the i-th square because the uncomfortable position of the ladder may make the characters untidy. Besides, the programmers can move the ladder. In one hour, they can move the ladder either a meter to the right or a meter to the left.Drawing characters and moving the ladder is very tiring, so the programmers want to finish the job in as little time as possible. Develop for them an optimal poster painting plan!
256 megabytes
import java.util.*; public class Practica_1 { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); int k = in.nextInt(); String ln = in.next(); int a = ln.length() - k; int b = k - 1; int c = 0; if (a <= b) { if (k != ln.length()) { int d = a; while (d != 0) { System.out.println("RIGHT"); d--; } } c = ln.length() - 1; } else { if (k != 1) { int d = b; while (d != 0) { System.out.println("LEFT"); d--; } } c = 0; } if (c == ln.length() - 1) { while (c >= 0) { if (c != 0) { System.out.println("PRINT " + ln.charAt(c)); System.out.println("LEFT"); } else { System.out.println("PRINT " + ln.charAt(c)); } c--; } } else { while (c < ln.length()) { if (c != ln.length() - 1) { System.out.println("PRINT " + ln.charAt(c)); System.out.println("RIGHT"); } else { System.out.println("PRINT " + ln.charAt(c)); } c++; } } } }
Java
["2 2\nR1", "2 1\nR1", "6 4\nGO?GO!"]
1 second
["PRINT 1\nLEFT\nPRINT R", "PRINT R\nRIGHT\nPRINT 1", "RIGHT\nRIGHT\nPRINT !\nLEFT\nPRINT O\nLEFT\nPRINT G\nLEFT\nPRINT ?\nLEFT\nPRINT O\nLEFT\nPRINT G"]
NoteNote that the ladder cannot be shifted by less than one meter. The ladder can only stand in front of some square of the poster. For example, you cannot shift a ladder by half a meter and position it between two squares. Then go up and paint the first character and the second character.
Java 7
standard input
[ "implementation", "greedy" ]
e3a03f3f01a77a1983121bab4218c39c
The first line contains two integers, n and k (1 ≤ k ≤ n ≤ 100) — the number of characters in the slogan and the initial position of the ladder, correspondingly. The next line contains the slogan as n characters written without spaces. Each character of the slogan is either a large English letter, or digit, or one of the characters: '.', '!', ',', '?'.
900
In t lines, print the actions the programmers need to make. In the i-th line print: "LEFT" (without the quotes), if the i-th action was "move the ladder to the left"; "RIGHT" (without the quotes), if the i-th action was "move the ladder to the right"; "PRINT x" (without the quotes), if the i-th action was to "go up the ladder, paint character x, go down the ladder". The painting time (variable t) must be minimum possible. If there are multiple optimal painting plans, you can print any of them.
standard output
PASSED
931148679f52564d1c0dd00750c3bc1c
train_002.jsonl
1397837400
The R1 company has recently bought a high rise building in the centre of Moscow for its main office. It's time to decorate the new office, and the first thing to do is to write the company's slogan above the main entrance to the building.The slogan of the company consists of n characters, so the decorators hung a large banner, n meters wide and 1 meter high, divided into n equal squares. The first character of the slogan must be in the first square (the leftmost) of the poster, the second character must be in the second square, and so on.Of course, the R1 programmers want to write the slogan on the poster themselves. To do this, they have a large (and a very heavy) ladder which was put exactly opposite the k-th square of the poster. To draw the i-th character of the slogan on the poster, you need to climb the ladder, standing in front of the i-th square of the poster. This action (along with climbing up and down the ladder) takes one hour for a painter. The painter is not allowed to draw characters in the adjacent squares when the ladder is in front of the i-th square because the uncomfortable position of the ladder may make the characters untidy. Besides, the programmers can move the ladder. In one hour, they can move the ladder either a meter to the right or a meter to the left.Drawing characters and moving the ladder is very tiring, so the programmers want to finish the job in as little time as possible. Develop for them an optimal poster painting plan!
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.math.BigInteger; import java.util.ArrayList; import java.util.Scanner; import java.util.StringTokenizer; import java.util.regex.Matcher; import java.util.regex.Pattern; /** * * @author Ammar.Eliwat */ public class TEST{ public static void main(String[] args) throws IOException { Scanner input = new Scanner(System.in); // BufferedReader buffer = new BufferedReader(new InputStreamReader(System.in)); // String str; //while ((str = buffer.readLine()) != null) { int n=input.nextInt(); int start=input.nextInt(); String A=input.next(); if(start==1){ for(int i=0;i<A.length();i++){ if(i==A.length()-1){System.out.println("PRINT "+A.charAt(i));continue;} System.out.println("PRINT "+A.charAt(i)); System.out.println("RIGHT"); } } else{ if(start==A.length()){ for(int i=A.length()-1;i>=0;i--){ if(i==0){ System.out.println("PRINT "+A.charAt(i)); continue; } System.out.println("PRINT "+A.charAt(i)); System.out.println("LEFT"); } } else{ start=start-1; n=n-1; int first=Math.abs(0-start); int end=Math.abs(start-n); int min=0; if(first<=end) min=first; else min=end; if(min==end){ for(int i=0;i<min;i++) System.out.println("RIGHT"); for(int i=A.length()-1;i>=0;i--){ if(i==0){ System.out.println("PRINT "+A.charAt(i));continue;} System.out.println("PRINT "+A.charAt(i)); System.out.println("LEFT"); } } else{ for(int i=0;i<min;i++) System.out.println("LEFT"); for(int i=0;i<A.length();i++){ if(i==A.length()-1){ System.out.println("PRINT "+A.charAt(i));continue;} System.out.println("PRINT "+A.charAt(i)); System.out.println("RIGHT"); } } } } // String A=input.next(); // String B=input.next(); // Pattern p= Pattern.compile(B+"$"); // Matcher m=p.matcher(A); // if(m.find()==true) // System.out.println("yes"); // else // System.out.println("no"); // // } } }
Java
["2 2\nR1", "2 1\nR1", "6 4\nGO?GO!"]
1 second
["PRINT 1\nLEFT\nPRINT R", "PRINT R\nRIGHT\nPRINT 1", "RIGHT\nRIGHT\nPRINT !\nLEFT\nPRINT O\nLEFT\nPRINT G\nLEFT\nPRINT ?\nLEFT\nPRINT O\nLEFT\nPRINT G"]
NoteNote that the ladder cannot be shifted by less than one meter. The ladder can only stand in front of some square of the poster. For example, you cannot shift a ladder by half a meter and position it between two squares. Then go up and paint the first character and the second character.
Java 7
standard input
[ "implementation", "greedy" ]
e3a03f3f01a77a1983121bab4218c39c
The first line contains two integers, n and k (1 ≤ k ≤ n ≤ 100) — the number of characters in the slogan and the initial position of the ladder, correspondingly. The next line contains the slogan as n characters written without spaces. Each character of the slogan is either a large English letter, or digit, or one of the characters: '.', '!', ',', '?'.
900
In t lines, print the actions the programmers need to make. In the i-th line print: "LEFT" (without the quotes), if the i-th action was "move the ladder to the left"; "RIGHT" (without the quotes), if the i-th action was "move the ladder to the right"; "PRINT x" (without the quotes), if the i-th action was to "go up the ladder, paint character x, go down the ladder". The painting time (variable t) must be minimum possible. If there are multiple optimal painting plans, you can print any of them.
standard output
PASSED
e89ae730a497822ea2738bb47325582b
train_002.jsonl
1397837400
The R1 company has recently bought a high rise building in the centre of Moscow for its main office. It's time to decorate the new office, and the first thing to do is to write the company's slogan above the main entrance to the building.The slogan of the company consists of n characters, so the decorators hung a large banner, n meters wide and 1 meter high, divided into n equal squares. The first character of the slogan must be in the first square (the leftmost) of the poster, the second character must be in the second square, and so on.Of course, the R1 programmers want to write the slogan on the poster themselves. To do this, they have a large (and a very heavy) ladder which was put exactly opposite the k-th square of the poster. To draw the i-th character of the slogan on the poster, you need to climb the ladder, standing in front of the i-th square of the poster. This action (along with climbing up and down the ladder) takes one hour for a painter. The painter is not allowed to draw characters in the adjacent squares when the ladder is in front of the i-th square because the uncomfortable position of the ladder may make the characters untidy. Besides, the programmers can move the ladder. In one hour, they can move the ladder either a meter to the right or a meter to the left.Drawing characters and moving the ladder is very tiring, so the programmers want to finish the job in as little time as possible. Develop for them an optimal poster painting plan!
256 megabytes
import java.io.*; import java.util.*; public class p412a { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int k = sc.nextInt(); String str = sc.next(); if(n==2*k) { if(k<=(n/2)) { for(int i=k;i>1;i--) System.out.println("LEFT"); for(int i=0;i<n-1;i++) { System.out.println("PRINT "+str.charAt(i)); System.out.println("RIGHT"); } System.out.println("PRINT "+str.charAt(n-1)); } else { for(int i=k;i<n-1;i++) System.out.println("RIGHT"); for(int i=n-1;i>1;i--) { System.out.println("PRINT "+str.charAt(i)); System.out.println("LEFT"); } System.out.println("PRINT "+str.charAt(0)); } } else if(2*k>n) { for(int i=k;k<n;k++) System.out.println("RIGHT"); for(int i=n-1;i>0;i--) { System.out.println("PRINT "+str.charAt(i)); System.out.println("LEFT"); } System.out.println("PRINT "+str.charAt(0)); } else if(2*k<n) { for(int i=k;k>1;k--) System.out.println("LEFT"); for(int i=0;i<n-1;i++) { System.out.println("PRINT "+str.charAt(i)); System.out.println("RIGHT"); } System.out.println("PRINT "+str.charAt(n-1)); } } }
Java
["2 2\nR1", "2 1\nR1", "6 4\nGO?GO!"]
1 second
["PRINT 1\nLEFT\nPRINT R", "PRINT R\nRIGHT\nPRINT 1", "RIGHT\nRIGHT\nPRINT !\nLEFT\nPRINT O\nLEFT\nPRINT G\nLEFT\nPRINT ?\nLEFT\nPRINT O\nLEFT\nPRINT G"]
NoteNote that the ladder cannot be shifted by less than one meter. The ladder can only stand in front of some square of the poster. For example, you cannot shift a ladder by half a meter and position it between two squares. Then go up and paint the first character and the second character.
Java 7
standard input
[ "implementation", "greedy" ]
e3a03f3f01a77a1983121bab4218c39c
The first line contains two integers, n and k (1 ≤ k ≤ n ≤ 100) — the number of characters in the slogan and the initial position of the ladder, correspondingly. The next line contains the slogan as n characters written without spaces. Each character of the slogan is either a large English letter, or digit, or one of the characters: '.', '!', ',', '?'.
900
In t lines, print the actions the programmers need to make. In the i-th line print: "LEFT" (without the quotes), if the i-th action was "move the ladder to the left"; "RIGHT" (without the quotes), if the i-th action was "move the ladder to the right"; "PRINT x" (without the quotes), if the i-th action was to "go up the ladder, paint character x, go down the ladder". The painting time (variable t) must be minimum possible. If there are multiple optimal painting plans, you can print any of them.
standard output
PASSED
21aacf94b03f42e582dbcb2911104087
train_002.jsonl
1397837400
The R1 company has recently bought a high rise building in the centre of Moscow for its main office. It's time to decorate the new office, and the first thing to do is to write the company's slogan above the main entrance to the building.The slogan of the company consists of n characters, so the decorators hung a large banner, n meters wide and 1 meter high, divided into n equal squares. The first character of the slogan must be in the first square (the leftmost) of the poster, the second character must be in the second square, and so on.Of course, the R1 programmers want to write the slogan on the poster themselves. To do this, they have a large (and a very heavy) ladder which was put exactly opposite the k-th square of the poster. To draw the i-th character of the slogan on the poster, you need to climb the ladder, standing in front of the i-th square of the poster. This action (along with climbing up and down the ladder) takes one hour for a painter. The painter is not allowed to draw characters in the adjacent squares when the ladder is in front of the i-th square because the uncomfortable position of the ladder may make the characters untidy. Besides, the programmers can move the ladder. In one hour, they can move the ladder either a meter to the right or a meter to the left.Drawing characters and moving the ladder is very tiring, so the programmers want to finish the job in as little time as possible. Develop for them an optimal poster painting plan!
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.PrintWriter; import java.io.Writer; import java.math.BigInteger; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the top * @author Shamir14 (amirhossein.shapoori@gmail.com) */ public class Main { public static void main(String[] args) { InputStream inputStream = System.in; OutputStream outputStream = System.out; InputReader in = new InputReader(inputStream); OutputWriter out = new OutputWriter(outputStream); TaskA solver = new TaskA(); solver.solve(1, in, out); out.close(); } } class TaskA { public void solve(int testNumber, InputReader in, OutputWriter out) { int n = in.readInt(); int k = in.readInt(); String banner = in.readLine(); int start = k - 1; int end = banner.length() - k; if(start < end){ for (int i = 0; i < start; i++) { out.printLine("LEFT"); } for (int i = 0; i < banner.length(); i++) { if(i!=0) out.printLine("RIGHT"); out.printLine("PRINT " + banner.charAt(i)); } } else{ for (int i = 0; i < end; i++) { out.printLine("RIGHT"); } for (int i = banner.length()-1; i >= 0; i--) { if(i!=banner.length()-1) out.printLine("LEFT"); out.printLine("PRINT " + banner.charAt(i)); } } } } class InputReader { // this IO reading - writing is provided by Egor Kulikov private InputStream stream; private byte[] buf = new byte[1024]; private int curChar; private int numChars; public InputReader(InputStream stream) { this.stream = stream; } public int read() { if (numChars == -1) throw new UnknownError(); if (curChar >= numChars) { curChar = 0; try { numChars = stream.read(buf); } catch (IOException e) { throw new UnknownError(); } if (numChars <= 0) return -1; } return buf[curChar++]; } public boolean hasNext(){ return peek()!=-1; } public int peek() { if (numChars == -1) return -1; if (curChar >= numChars) { curChar = 0; try { numChars = stream.read(buf); } catch (IOException e) { return -1; } if (numChars <= 0) return -1; } return buf[curChar]; } public int readInt() { int c = read(); while (isSpaceChar(c)) c = read(); int sgn = 1; if (c == '-') { sgn = -1; c = read(); } int res = 0; do { if (c < '0' || c > '9') throw new UnknownError(); res *= 10; res += c - '0'; c = read(); } while (!isSpaceChar(c)); return res * sgn; } public long readLong() { int c = read(); while (isSpaceChar(c)) c = read(); int sgn = 1; if (c == '-') { sgn = -1; c = read(); } long res = 0; do { if (c < '0' || c > '9') throw new UnknownError(); res *= 10; res += c - '0'; c = read(); } while (!isSpaceChar(c)); return res * sgn; } public String readString() { int c = read(); while (isSpaceChar(c)) c = read(); StringBuffer res = new StringBuffer(); do { res.appendCodePoint(c); c = read(); } while (!isSpaceChar(c)); return res.toString(); } public static boolean isSpaceChar(int c) { return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1; } private String readLine0() { StringBuffer buf = new StringBuffer(); int c = read(); while (c != '\n' && c != -1) { if (c != '\r') buf.appendCodePoint(c); c = read(); } return buf.toString(); } public String readLine() { String s = readLine0(); while (s.trim().length() == 0) s = readLine0(); return s; } public String readLine(boolean ignoreEmptyLines) { if (ignoreEmptyLines) return readLine(); else return readLine0(); } public BigInteger readBigInteger() { try { return new BigInteger(readString()); } catch (NumberFormatException e) { throw new UnknownError(); } } public char readCharacter() { int c = read(); while (isSpaceChar(c)) c = read(); return (char) c; } public double readDouble() { int c = read(); while (isSpaceChar(c)) c = read(); int sgn = 1; if (c == '-') { sgn = -1; c = read(); } double res = 0; while (!isSpaceChar(c) && c != '.') { if (c == 'e' || c == 'E') return res * Math.pow(10, readInt()); if (c < '0' || c > '9') throw new UnknownError(); res *= 10; res += c - '0'; c = read(); } if (c == '.') { c = read(); double m = 1; while (!isSpaceChar(c)) { if (c == 'e' || c == 'E') return res * Math.pow(10, readInt()); if (c < '0' || c > '9') throw new UnknownError(); m /= 10; res += (c - '0') * m; c = read(); } } return res * sgn; } public boolean isExhausted() { int value; while (isSpaceChar(value = peek()) && value != -1) read(); return value == -1; } public String next() { return readString(); } } class OutputWriter { private final PrintWriter writer; public OutputWriter(OutputStream outputStream) { writer = new PrintWriter(outputStream); } public OutputWriter(Writer writer) { this.writer = new PrintWriter(writer); } public void print(Object...objects) { for (int i = 0; i < objects.length; i++) { if (i != 0) writer.print(' '); writer.print(objects[i]); } } public void printLine(Object...objects) { print(objects); writer.println(); } public void printLine(char[] array) { writer.println(array); } public void printFormat(String format, Object...objects) { writer.printf(format, objects); } public void close() { writer.close(); } public void flush() { writer.flush(); } }
Java
["2 2\nR1", "2 1\nR1", "6 4\nGO?GO!"]
1 second
["PRINT 1\nLEFT\nPRINT R", "PRINT R\nRIGHT\nPRINT 1", "RIGHT\nRIGHT\nPRINT !\nLEFT\nPRINT O\nLEFT\nPRINT G\nLEFT\nPRINT ?\nLEFT\nPRINT O\nLEFT\nPRINT G"]
NoteNote that the ladder cannot be shifted by less than one meter. The ladder can only stand in front of some square of the poster. For example, you cannot shift a ladder by half a meter and position it between two squares. Then go up and paint the first character and the second character.
Java 7
standard input
[ "implementation", "greedy" ]
e3a03f3f01a77a1983121bab4218c39c
The first line contains two integers, n and k (1 ≤ k ≤ n ≤ 100) — the number of characters in the slogan and the initial position of the ladder, correspondingly. The next line contains the slogan as n characters written without spaces. Each character of the slogan is either a large English letter, or digit, or one of the characters: '.', '!', ',', '?'.
900
In t lines, print the actions the programmers need to make. In the i-th line print: "LEFT" (without the quotes), if the i-th action was "move the ladder to the left"; "RIGHT" (without the quotes), if the i-th action was "move the ladder to the right"; "PRINT x" (without the quotes), if the i-th action was to "go up the ladder, paint character x, go down the ladder". The painting time (variable t) must be minimum possible. If there are multiple optimal painting plans, you can print any of them.
standard output
PASSED
192b61d569ed85239679c23980deb542
train_002.jsonl
1397837400
The R1 company has recently bought a high rise building in the centre of Moscow for its main office. It's time to decorate the new office, and the first thing to do is to write the company's slogan above the main entrance to the building.The slogan of the company consists of n characters, so the decorators hung a large banner, n meters wide and 1 meter high, divided into n equal squares. The first character of the slogan must be in the first square (the leftmost) of the poster, the second character must be in the second square, and so on.Of course, the R1 programmers want to write the slogan on the poster themselves. To do this, they have a large (and a very heavy) ladder which was put exactly opposite the k-th square of the poster. To draw the i-th character of the slogan on the poster, you need to climb the ladder, standing in front of the i-th square of the poster. This action (along with climbing up and down the ladder) takes one hour for a painter. The painter is not allowed to draw characters in the adjacent squares when the ladder is in front of the i-th square because the uncomfortable position of the ladder may make the characters untidy. Besides, the programmers can move the ladder. In one hour, they can move the ladder either a meter to the right or a meter to the left.Drawing characters and moving the ladder is very tiring, so the programmers want to finish the job in as little time as possible. Develop for them an optimal poster painting plan!
256 megabytes
import java.util.*; import java.io.*; import java.awt.Point; import java.math.BigDecimal; import java.math.BigInteger; import static java.lang.Math.*; // Solution is at the bottom of code public class A implements Runnable{ final boolean ONLINE_JUDGE = System.getProperty("ONLINE_JUDGE") != null; BufferedReader in; OutputWriter out; StringTokenizer tok = new StringTokenizer(""); public static void main(String[] args){ new Thread(null, new A(), "", 128 * (1L << 20)).start(); } ///////////////////////////////////////////////////////////////////// void init() throws FileNotFoundException{ Locale.setDefault(Locale.US); if (ONLINE_JUDGE){ in = new BufferedReader(new InputStreamReader(System.in)); out = new OutputWriter(System.out); }else{ in = new BufferedReader(new FileReader("input.txt")); out = new OutputWriter("output.txt"); } } //////////////////////////////////////////////////////////////// long timeBegin, timeEnd; void time(){ timeEnd = System.currentTimeMillis(); System.err.println("Time = " + (timeEnd - timeBegin)); } void debug(Object... objects){ if (ONLINE_JUDGE){ for (Object o: objects){ System.err.println(o.toString()); } } } ///////////////////////////////////////////////////////////////////// public void run(){ try{ timeBegin = System.currentTimeMillis(); Locale.setDefault(Locale.US); init(); solve(); out.close(); time(); }catch (Exception e){ e.printStackTrace(System.err); System.exit(-1); } } ///////////////////////////////////////////////////////////////////// String delim = " "; String readString() throws IOException{ while(!tok.hasMoreTokens()){ try{ tok = new StringTokenizer(in.readLine()); }catch (Exception e){ return null; } } return tok.nextToken(delim); } String readLine() throws IOException{ return in.readLine(); } ///////////////////////////////////////////////////////////////// final char NOT_A_SYMBOL = '\0'; char readChar() throws IOException{ int intValue = in.read(); if (intValue == -1){ return NOT_A_SYMBOL; } return (char) intValue; } char[] readCharArray() throws IOException{ return readLine().toCharArray(); } ///////////////////////////////////////////////////////////////// int readInt() throws IOException { return Integer.parseInt(readString()); } int[] readIntArray(int size) throws IOException { int[] array = new int[size]; for (int index = 0; index < size; ++index){ array[index] = readInt(); } return array; } int[] readIntArrayWithDecrease(int size) throws IOException { int[] array = readIntArray(size); for (int i = 0; i < size; ++i) { array[i]--; } return array; } /////////////////////////////////////////////////////////////////// int[][] readIntMatrix(int rowsCount, int columnsCount) throws IOException { int[][] matrix = new int[rowsCount][]; for (int rowIndex = 0; rowIndex < rowsCount; ++rowIndex) { matrix[rowIndex] = readIntArray(columnsCount); } return matrix; } int[][] readIntMatrixWithDecrease(int rowsCount, int columnsCount) throws IOException { int[][] matrix = new int[rowsCount][]; for (int rowIndex = 0; rowIndex < rowsCount; ++rowIndex) { matrix[rowIndex] = readIntArrayWithDecrease(columnsCount); } return matrix; } /////////////////////////////////////////////////////////////////// long readLong() throws IOException{ return Long.parseLong(readString()); } long[] readLongArray(int size) throws IOException{ long[] array = new long[size]; for (int index = 0; index < size; ++index){ array[index] = readLong(); } return array; } //////////////////////////////////////////////////////////////////// double readDouble() throws IOException{ return Double.parseDouble(readString()); } double[] readDoubleArray(int size) throws IOException{ double[] array = new double[size]; for (int index = 0; index < size; ++index){ array[index] = readDouble(); } return array; } //////////////////////////////////////////////////////////////////// BigInteger readBigInteger() throws IOException { return new BigInteger(readString()); } BigDecimal readBigDecimal() throws IOException { return new BigDecimal(readString()); } ///////////////////////////////////////////////////////////////////// Point readPoint() throws IOException{ int x = readInt(); int y = readInt(); return new Point(x, y); } Point[] readPointArray(int size) throws IOException{ Point[] array = new Point[size]; for (int index = 0; index < size; ++index){ array[index] = readPoint(); } return array; } ///////////////////////////////////////////////////////////////////// List<Integer>[] readGraph(int vertexNumber, int edgeNumber) throws IOException{ @SuppressWarnings("unchecked") List<Integer>[] graph = new List[vertexNumber]; for (int index = 0; index < vertexNumber; ++index){ graph[index] = new ArrayList<Integer>(); } while (edgeNumber-- > 0){ int from = readInt() - 1; int to = readInt() - 1; graph[from].add(to); graph[to].add(from); } return graph; } ///////////////////////////////////////////////////////////////////// static class IntIndexPair { static Comparator<IntIndexPair> increaseComparator = new Comparator<A.IntIndexPair>() { @Override public int compare(IntIndexPair indexPair1, IntIndexPair indexPair2) { int value1 = indexPair1.value; int value2 = indexPair2.value; if (value1 != value2) return value1 - value2; int index1 = indexPair1.index; int index2 = indexPair2.index; return index1 - index2; } }; static Comparator<IntIndexPair> decreaseComparator = new Comparator<A.IntIndexPair>() { @Override public int compare(IntIndexPair indexPair1, IntIndexPair indexPair2) { int value1 = indexPair1.value; int value2 = indexPair2.value; if (value1 != value2) return -(value1 - value2); int index1 = indexPair1.index; int index2 = indexPair2.index; return index1 - index2; } }; int value, index; public IntIndexPair(int value, int index) { super(); this.value = value; this.index = index; } public int getRealIndex() { return index + 1; } } IntIndexPair[] readIntIndexArray(int size) throws IOException { IntIndexPair[] array = new IntIndexPair[size]; for (int index = 0; index < size; ++index) { array[index] = new IntIndexPair(readInt(), index); } return array; } ///////////////////////////////////////////////////////////////////// static class OutputWriter extends PrintWriter{ final int DEFAULT_PRECISION = 12; int precision; String format, formatWithSpace; { precision = DEFAULT_PRECISION; format = createFormat(precision); formatWithSpace = format + " "; } public OutputWriter(OutputStream out) { super(out); } public OutputWriter(String fileName) throws FileNotFoundException { super(fileName); } public int getPrecision() { return precision; } public void setPrecision(int precision) { precision = max(0, precision); this.precision = precision; format = createFormat(precision); formatWithSpace = format + " "; } private String createFormat(int precision){ return "%." + precision + "f"; } @Override public void print(double d){ printf(format, d); } public void printWithSpace(double d){ printf(formatWithSpace, d); } public void printAll(double...d){ for (int i = 0; i < d.length - 1; ++i){ printWithSpace(d[i]); } print(d[d.length - 1]); } @Override public void println(double d){ printlnAll(d); } public void printlnAll(double... d){ printAll(d); println(); } } ///////////////////////////////////////////////////////////////////// int[][] steps = {{-1, 0}, {1, 0}, {0, -1}, {0, 1}}; int[][] steps8 = { {-1, 0}, {1, 0}, {0, -1}, {0, 1}, {-1, -1}, {1, 1}, {1, -1}, {-1, 1} }; boolean check(int index, int lim){ return (0 <= index && index < lim); } ///////////////////////////////////////////////////////////////////// boolean checkBit(int mask, int bit){ return (mask & (1 << bit)) != 0; } ///////////////////////////////////////////////////////////////////// void solve() throws IOException { int messageLength = readInt(); int currentIndex = readInt() - 1; char[] message = readCharArray(); final String LEFT = "LEFT", RIGHT = "RIGHT", PRINT = "PRINT "; if (currentIndex <= messageLength - currentIndex - 1) { while (currentIndex --> 0) { out.println(LEFT); } out.println(PRINT + message[0]); for (int index = 1; index < message.length; ++index) { out.println(RIGHT); out.println(PRINT + message[index]); } } else { while (++currentIndex < messageLength) { out.println(RIGHT); } out.println(PRINT + message[messageLength - 1]); for (int index = messageLength - 2; index >= 0; --index) { out.println(LEFT); out.println(PRINT + message[index]); } } } }
Java
["2 2\nR1", "2 1\nR1", "6 4\nGO?GO!"]
1 second
["PRINT 1\nLEFT\nPRINT R", "PRINT R\nRIGHT\nPRINT 1", "RIGHT\nRIGHT\nPRINT !\nLEFT\nPRINT O\nLEFT\nPRINT G\nLEFT\nPRINT ?\nLEFT\nPRINT O\nLEFT\nPRINT G"]
NoteNote that the ladder cannot be shifted by less than one meter. The ladder can only stand in front of some square of the poster. For example, you cannot shift a ladder by half a meter and position it between two squares. Then go up and paint the first character and the second character.
Java 7
standard input
[ "implementation", "greedy" ]
e3a03f3f01a77a1983121bab4218c39c
The first line contains two integers, n and k (1 ≤ k ≤ n ≤ 100) — the number of characters in the slogan and the initial position of the ladder, correspondingly. The next line contains the slogan as n characters written without spaces. Each character of the slogan is either a large English letter, or digit, or one of the characters: '.', '!', ',', '?'.
900
In t lines, print the actions the programmers need to make. In the i-th line print: "LEFT" (without the quotes), if the i-th action was "move the ladder to the left"; "RIGHT" (without the quotes), if the i-th action was "move the ladder to the right"; "PRINT x" (without the quotes), if the i-th action was to "go up the ladder, paint character x, go down the ladder". The painting time (variable t) must be minimum possible. If there are multiple optimal painting plans, you can print any of them.
standard output
PASSED
c7e272ee51ada0c1e2bec5512e1d98c5
train_002.jsonl
1397837400
The R1 company has recently bought a high rise building in the centre of Moscow for its main office. It's time to decorate the new office, and the first thing to do is to write the company's slogan above the main entrance to the building.The slogan of the company consists of n characters, so the decorators hung a large banner, n meters wide and 1 meter high, divided into n equal squares. The first character of the slogan must be in the first square (the leftmost) of the poster, the second character must be in the second square, and so on.Of course, the R1 programmers want to write the slogan on the poster themselves. To do this, they have a large (and a very heavy) ladder which was put exactly opposite the k-th square of the poster. To draw the i-th character of the slogan on the poster, you need to climb the ladder, standing in front of the i-th square of the poster. This action (along with climbing up and down the ladder) takes one hour for a painter. The painter is not allowed to draw characters in the adjacent squares when the ladder is in front of the i-th square because the uncomfortable position of the ladder may make the characters untidy. Besides, the programmers can move the ladder. In one hour, they can move the ladder either a meter to the right or a meter to the left.Drawing characters and moving the ladder is very tiring, so the programmers want to finish the job in as little time as possible. Develop for them an optimal poster painting plan!
256 megabytes
import java.io.*; import java.util.*; public class CoderStrikeA { private static StringTokenizer st; public static void nextLine(BufferedReader br) throws IOException { st = new StringTokenizer(br.readLine()); } public static int nextInt() { return Integer.parseInt(st.nextToken()); } public static String next() { return st.nextToken(); } public static long nextLong() { return Long.parseLong(st.nextToken()); } public static double nextDouble() { return Double.parseDouble(st.nextToken()); } public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); nextLine(br); int n = nextInt(); int k = nextInt() - 1; nextLine(br); String s = next(); StringBuffer sb = new StringBuffer(); if (k < n-k-1) { sb.append("PRINT " + s.charAt(k) + "\n"); for (int i = k-1; i >= 0; i--) { sb.append("LEFT\n"); sb.append("PRINT " + s.charAt(i) + "\n"); } for (int i = 0; i < k; i++) { sb.append("RIGHT\n"); } for (int i = k+1; i < n; i++) { sb.append("RIGHT\n"); sb.append("PRINT " + s.charAt(i) + "\n"); } } else { sb.append("PRINT " + s.charAt(k) + "\n"); for (int i = k+1; i < n; i++) { sb.append("RIGHT\n"); sb.append("PRINT " + s.charAt(i) + "\n"); } for (int i = n-1; i > k; i--) { sb.append("LEFT\n"); } for (int i = k-1; i >= 0; i--) { sb.append("LEFT\n"); sb.append("PRINT " + s.charAt(i) + "\n"); } } System.out.println(sb.toString()); } }
Java
["2 2\nR1", "2 1\nR1", "6 4\nGO?GO!"]
1 second
["PRINT 1\nLEFT\nPRINT R", "PRINT R\nRIGHT\nPRINT 1", "RIGHT\nRIGHT\nPRINT !\nLEFT\nPRINT O\nLEFT\nPRINT G\nLEFT\nPRINT ?\nLEFT\nPRINT O\nLEFT\nPRINT G"]
NoteNote that the ladder cannot be shifted by less than one meter. The ladder can only stand in front of some square of the poster. For example, you cannot shift a ladder by half a meter and position it between two squares. Then go up and paint the first character and the second character.
Java 7
standard input
[ "implementation", "greedy" ]
e3a03f3f01a77a1983121bab4218c39c
The first line contains two integers, n and k (1 ≤ k ≤ n ≤ 100) — the number of characters in the slogan and the initial position of the ladder, correspondingly. The next line contains the slogan as n characters written without spaces. Each character of the slogan is either a large English letter, or digit, or one of the characters: '.', '!', ',', '?'.
900
In t lines, print the actions the programmers need to make. In the i-th line print: "LEFT" (without the quotes), if the i-th action was "move the ladder to the left"; "RIGHT" (without the quotes), if the i-th action was "move the ladder to the right"; "PRINT x" (without the quotes), if the i-th action was to "go up the ladder, paint character x, go down the ladder". The painting time (variable t) must be minimum possible. If there are multiple optimal painting plans, you can print any of them.
standard output
PASSED
698a81597aa1c0e2cef96d10537af56f
train_002.jsonl
1397837400
The R1 company has recently bought a high rise building in the centre of Moscow for its main office. It's time to decorate the new office, and the first thing to do is to write the company's slogan above the main entrance to the building.The slogan of the company consists of n characters, so the decorators hung a large banner, n meters wide and 1 meter high, divided into n equal squares. The first character of the slogan must be in the first square (the leftmost) of the poster, the second character must be in the second square, and so on.Of course, the R1 programmers want to write the slogan on the poster themselves. To do this, they have a large (and a very heavy) ladder which was put exactly opposite the k-th square of the poster. To draw the i-th character of the slogan on the poster, you need to climb the ladder, standing in front of the i-th square of the poster. This action (along with climbing up and down the ladder) takes one hour for a painter. The painter is not allowed to draw characters in the adjacent squares when the ladder is in front of the i-th square because the uncomfortable position of the ladder may make the characters untidy. Besides, the programmers can move the ladder. In one hour, they can move the ladder either a meter to the right or a meter to the left.Drawing characters and moving the ladder is very tiring, so the programmers want to finish the job in as little time as possible. Develop for them an optimal poster painting plan!
256 megabytes
import java.io.PrintStream; import java.util.Scanner; public class A { public static void main(String[] args) { Scanner in = new Scanner(System.in); PrintStream out = System.out; int n = in.nextInt(); int k = in.nextInt(); in.nextLine(); char[] s = in.nextLine().toCharArray(); if (k * 2 <= n) { while (k-- > 1) out.println("LEFT"); for (k = 0; k < n; k++) { out.println("PRINT " + s[k]); if (k != n - 1) out.println("RIGHT"); } } else { while (k++ < n) out.println("RIGHT"); for (k = n - 1; k >= 0; k--) { out.println("PRINT " + s[k]); if (k != 0) out.println("LEFT"); } } } }
Java
["2 2\nR1", "2 1\nR1", "6 4\nGO?GO!"]
1 second
["PRINT 1\nLEFT\nPRINT R", "PRINT R\nRIGHT\nPRINT 1", "RIGHT\nRIGHT\nPRINT !\nLEFT\nPRINT O\nLEFT\nPRINT G\nLEFT\nPRINT ?\nLEFT\nPRINT O\nLEFT\nPRINT G"]
NoteNote that the ladder cannot be shifted by less than one meter. The ladder can only stand in front of some square of the poster. For example, you cannot shift a ladder by half a meter and position it between two squares. Then go up and paint the first character and the second character.
Java 7
standard input
[ "implementation", "greedy" ]
e3a03f3f01a77a1983121bab4218c39c
The first line contains two integers, n and k (1 ≤ k ≤ n ≤ 100) — the number of characters in the slogan and the initial position of the ladder, correspondingly. The next line contains the slogan as n characters written without spaces. Each character of the slogan is either a large English letter, or digit, or one of the characters: '.', '!', ',', '?'.
900
In t lines, print the actions the programmers need to make. In the i-th line print: "LEFT" (without the quotes), if the i-th action was "move the ladder to the left"; "RIGHT" (without the quotes), if the i-th action was "move the ladder to the right"; "PRINT x" (without the quotes), if the i-th action was to "go up the ladder, paint character x, go down the ladder". The painting time (variable t) must be minimum possible. If there are multiple optimal painting plans, you can print any of them.
standard output
PASSED
0c3a9ba7d968c2f9ec1fba04ec3a7030
train_002.jsonl
1397837400
The R1 company has recently bought a high rise building in the centre of Moscow for its main office. It's time to decorate the new office, and the first thing to do is to write the company's slogan above the main entrance to the building.The slogan of the company consists of n characters, so the decorators hung a large banner, n meters wide and 1 meter high, divided into n equal squares. The first character of the slogan must be in the first square (the leftmost) of the poster, the second character must be in the second square, and so on.Of course, the R1 programmers want to write the slogan on the poster themselves. To do this, they have a large (and a very heavy) ladder which was put exactly opposite the k-th square of the poster. To draw the i-th character of the slogan on the poster, you need to climb the ladder, standing in front of the i-th square of the poster. This action (along with climbing up and down the ladder) takes one hour for a painter. The painter is not allowed to draw characters in the adjacent squares when the ladder is in front of the i-th square because the uncomfortable position of the ladder may make the characters untidy. Besides, the programmers can move the ladder. In one hour, they can move the ladder either a meter to the right or a meter to the left.Drawing characters and moving the ladder is very tiring, so the programmers want to finish the job in as little time as possible. Develop for them an optimal poster painting plan!
256 megabytes
import java.math.BigInteger; import java.util.Scanner; public class a { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int k = sc.nextInt(); String s = sc.next(); if (n / 2 < k) { for (int i = 1; i <=n-k; i++) { System.out.println("RIGHT"); } for (int i = n; i >=1; i--) { System.out.println("PRINT "+s.charAt(i-1)); if(i!=1) System.out.println("LEFT"); } }else{ for (int i = 1; i <=k-1; i++) { System.out.println("LEFT"); } for (int i = 1; i <=n; i++) { System.out.println("PRINT "+s.charAt(i-1)); if(n!=i) System.out.println("RIGHT"); } } } }
Java
["2 2\nR1", "2 1\nR1", "6 4\nGO?GO!"]
1 second
["PRINT 1\nLEFT\nPRINT R", "PRINT R\nRIGHT\nPRINT 1", "RIGHT\nRIGHT\nPRINT !\nLEFT\nPRINT O\nLEFT\nPRINT G\nLEFT\nPRINT ?\nLEFT\nPRINT O\nLEFT\nPRINT G"]
NoteNote that the ladder cannot be shifted by less than one meter. The ladder can only stand in front of some square of the poster. For example, you cannot shift a ladder by half a meter and position it between two squares. Then go up and paint the first character and the second character.
Java 7
standard input
[ "implementation", "greedy" ]
e3a03f3f01a77a1983121bab4218c39c
The first line contains two integers, n and k (1 ≤ k ≤ n ≤ 100) — the number of characters in the slogan and the initial position of the ladder, correspondingly. The next line contains the slogan as n characters written without spaces. Each character of the slogan is either a large English letter, or digit, or one of the characters: '.', '!', ',', '?'.
900
In t lines, print the actions the programmers need to make. In the i-th line print: "LEFT" (without the quotes), if the i-th action was "move the ladder to the left"; "RIGHT" (without the quotes), if the i-th action was "move the ladder to the right"; "PRINT x" (without the quotes), if the i-th action was to "go up the ladder, paint character x, go down the ladder". The painting time (variable t) must be minimum possible. If there are multiple optimal painting plans, you can print any of them.
standard output
PASSED
33c5e2d81c84948a4fad4fd2fae4f3f5
train_002.jsonl
1397837400
The R1 company has recently bought a high rise building in the centre of Moscow for its main office. It's time to decorate the new office, and the first thing to do is to write the company's slogan above the main entrance to the building.The slogan of the company consists of n characters, so the decorators hung a large banner, n meters wide and 1 meter high, divided into n equal squares. The first character of the slogan must be in the first square (the leftmost) of the poster, the second character must be in the second square, and so on.Of course, the R1 programmers want to write the slogan on the poster themselves. To do this, they have a large (and a very heavy) ladder which was put exactly opposite the k-th square of the poster. To draw the i-th character of the slogan on the poster, you need to climb the ladder, standing in front of the i-th square of the poster. This action (along with climbing up and down the ladder) takes one hour for a painter. The painter is not allowed to draw characters in the adjacent squares when the ladder is in front of the i-th square because the uncomfortable position of the ladder may make the characters untidy. Besides, the programmers can move the ladder. In one hour, they can move the ladder either a meter to the right or a meter to the left.Drawing characters and moving the ladder is very tiring, so the programmers want to finish the job in as little time as possible. Develop for them an optimal poster painting plan!
256 megabytes
import java.util.Scanner; public class A { public static void main(String[] args) { Scanner sc = new Scanner(System.in); sc.nextInt(); int k = sc.nextInt()-1; char str[] = sc.next().toCharArray(); if(k < str.length-k-1) { for(;k > 0; k--) { System.out.println("LEFT"); } System.out.println("PRINT "+str[k]); for(;k < str.length-1;) { System.out.println("RIGHT"); k++; System.out.println("PRINT "+str[k]); } } else { for(;k < str.length-1; k++) { System.out.println("RIGHT"); } System.out.println("PRINT "+str[k]); for(;k > 0;) { System.out.println("LEFT"); k--; System.out.println("PRINT "+str[k]); } } } }
Java
["2 2\nR1", "2 1\nR1", "6 4\nGO?GO!"]
1 second
["PRINT 1\nLEFT\nPRINT R", "PRINT R\nRIGHT\nPRINT 1", "RIGHT\nRIGHT\nPRINT !\nLEFT\nPRINT O\nLEFT\nPRINT G\nLEFT\nPRINT ?\nLEFT\nPRINT O\nLEFT\nPRINT G"]
NoteNote that the ladder cannot be shifted by less than one meter. The ladder can only stand in front of some square of the poster. For example, you cannot shift a ladder by half a meter and position it between two squares. Then go up and paint the first character and the second character.
Java 7
standard input
[ "implementation", "greedy" ]
e3a03f3f01a77a1983121bab4218c39c
The first line contains two integers, n and k (1 ≤ k ≤ n ≤ 100) — the number of characters in the slogan and the initial position of the ladder, correspondingly. The next line contains the slogan as n characters written without spaces. Each character of the slogan is either a large English letter, or digit, or one of the characters: '.', '!', ',', '?'.
900
In t lines, print the actions the programmers need to make. In the i-th line print: "LEFT" (without the quotes), if the i-th action was "move the ladder to the left"; "RIGHT" (without the quotes), if the i-th action was "move the ladder to the right"; "PRINT x" (without the quotes), if the i-th action was to "go up the ladder, paint character x, go down the ladder". The painting time (variable t) must be minimum possible. If there are multiple optimal painting plans, you can print any of them.
standard output
PASSED
8ce1b049fbb5960859b3e8f512302620
train_002.jsonl
1397837400
The R1 company has recently bought a high rise building in the centre of Moscow for its main office. It's time to decorate the new office, and the first thing to do is to write the company's slogan above the main entrance to the building.The slogan of the company consists of n characters, so the decorators hung a large banner, n meters wide and 1 meter high, divided into n equal squares. The first character of the slogan must be in the first square (the leftmost) of the poster, the second character must be in the second square, and so on.Of course, the R1 programmers want to write the slogan on the poster themselves. To do this, they have a large (and a very heavy) ladder which was put exactly opposite the k-th square of the poster. To draw the i-th character of the slogan on the poster, you need to climb the ladder, standing in front of the i-th square of the poster. This action (along with climbing up and down the ladder) takes one hour for a painter. The painter is not allowed to draw characters in the adjacent squares when the ladder is in front of the i-th square because the uncomfortable position of the ladder may make the characters untidy. Besides, the programmers can move the ladder. In one hour, they can move the ladder either a meter to the right or a meter to the left.Drawing characters and moving the ladder is very tiring, so the programmers want to finish the job in as little time as possible. Develop for them an optimal poster painting plan!
256 megabytes
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); int len=0,pos=0,key=0; String slogan=""; len = in.nextInt(); pos = in.nextInt(); in.nextLine(); slogan = in.nextLine(); if (pos==1) key=0; else if (pos==len) key=1; else if (pos>(int)len/2){ key=1; for (int i=0;i<len-pos;i++) System.out.println("RIGHT"); } else { key=0; for (int i=0;i<pos-1;i++) System.out.println("LEFT"); } if (key==0){ for (int i=0;i<len;i++){ System.out.println("PRINT "+slogan.charAt(i)); if (i!= len-1) System.out.println("RIGHT"); } } else{ for (int i=len-1;i>=0;i--){ System.out.println("PRINT "+slogan.charAt(i)); if (i!=0) System.out.println("LEFT"); } } } }
Java
["2 2\nR1", "2 1\nR1", "6 4\nGO?GO!"]
1 second
["PRINT 1\nLEFT\nPRINT R", "PRINT R\nRIGHT\nPRINT 1", "RIGHT\nRIGHT\nPRINT !\nLEFT\nPRINT O\nLEFT\nPRINT G\nLEFT\nPRINT ?\nLEFT\nPRINT O\nLEFT\nPRINT G"]
NoteNote that the ladder cannot be shifted by less than one meter. The ladder can only stand in front of some square of the poster. For example, you cannot shift a ladder by half a meter and position it between two squares. Then go up and paint the first character and the second character.
Java 7
standard input
[ "implementation", "greedy" ]
e3a03f3f01a77a1983121bab4218c39c
The first line contains two integers, n and k (1 ≤ k ≤ n ≤ 100) — the number of characters in the slogan and the initial position of the ladder, correspondingly. The next line contains the slogan as n characters written without spaces. Each character of the slogan is either a large English letter, or digit, or one of the characters: '.', '!', ',', '?'.
900
In t lines, print the actions the programmers need to make. In the i-th line print: "LEFT" (without the quotes), if the i-th action was "move the ladder to the left"; "RIGHT" (without the quotes), if the i-th action was "move the ladder to the right"; "PRINT x" (without the quotes), if the i-th action was to "go up the ladder, paint character x, go down the ladder". The painting time (variable t) must be minimum possible. If there are multiple optimal painting plans, you can print any of them.
standard output
PASSED
bbe108159b6915475c207bf6e94fcf85
train_002.jsonl
1397837400
The R1 company has recently bought a high rise building in the centre of Moscow for its main office. It's time to decorate the new office, and the first thing to do is to write the company's slogan above the main entrance to the building.The slogan of the company consists of n characters, so the decorators hung a large banner, n meters wide and 1 meter high, divided into n equal squares. The first character of the slogan must be in the first square (the leftmost) of the poster, the second character must be in the second square, and so on.Of course, the R1 programmers want to write the slogan on the poster themselves. To do this, they have a large (and a very heavy) ladder which was put exactly opposite the k-th square of the poster. To draw the i-th character of the slogan on the poster, you need to climb the ladder, standing in front of the i-th square of the poster. This action (along with climbing up and down the ladder) takes one hour for a painter. The painter is not allowed to draw characters in the adjacent squares when the ladder is in front of the i-th square because the uncomfortable position of the ladder may make the characters untidy. Besides, the programmers can move the ladder. In one hour, they can move the ladder either a meter to the right or a meter to the left.Drawing characters and moving the ladder is very tiring, so the programmers want to finish the job in as little time as possible. Develop for them an optimal poster painting plan!
256 megabytes
/** * Created with IntelliJ IDEA. * User: den * Date: 4/18/14 * Time: 11:49 PM * To change this template use File | Settings | File Templates. */ import java.io.*; import java.util.*; public class TaskA extends Thread { private void solve() throws IOException { int n = _int(); int k = _int()-1; String s = nextToken(); if (k > n - k - 1) { while (k < n -1){ out.println("RIGHT"); k++; } while (k > 0){ out.println("PRINT " + s.charAt(k)); out.println("LEFT"); k--; } out.println("PRINT " + s.charAt(0)); } else{ while (k > 0){ out.println("LEFT"); k--; } while (k < n-1){ out.println("PRINT " + s.charAt(k)); out.println("RIGHT"); k++; } out.println("PRINT " + s.charAt(n-1)); } } public void run() { try { solve(); } catch (Exception e) { System.out.println("System exiting...."); e.printStackTrace(); System.exit(888); } finally { out.flush(); out.close(); } } public static void main(String[] args) throws FileNotFoundException { new TaskA().run(); } public TaskA() throws FileNotFoundException { //in = new BufferedReader(new FileReader("A-large.in")); //out = new PrintWriter(new File("A-large.out")); in = new BufferedReader(new InputStreamReader(System.in)); out = new PrintWriter(System.out); setPriority(Thread.MAX_PRIORITY); } private BufferedReader in; private PrintWriter out; private StringTokenizer st; private int _int() throws IOException { return Integer.parseInt(nextToken()); } private double _double() throws IOException { return Double.parseDouble(nextToken()); } private long _long() throws IOException { return Long.parseLong(nextToken()); } private char[] _chars() throws IOException { return nextToken().toCharArray(); } private String nextToken() throws IOException { if (st == null || !st.hasMoreElements()) st = new StringTokenizer(in.readLine(), " \t\r\n"); return st.nextToken(); } }
Java
["2 2\nR1", "2 1\nR1", "6 4\nGO?GO!"]
1 second
["PRINT 1\nLEFT\nPRINT R", "PRINT R\nRIGHT\nPRINT 1", "RIGHT\nRIGHT\nPRINT !\nLEFT\nPRINT O\nLEFT\nPRINT G\nLEFT\nPRINT ?\nLEFT\nPRINT O\nLEFT\nPRINT G"]
NoteNote that the ladder cannot be shifted by less than one meter. The ladder can only stand in front of some square of the poster. For example, you cannot shift a ladder by half a meter and position it between two squares. Then go up and paint the first character and the second character.
Java 7
standard input
[ "implementation", "greedy" ]
e3a03f3f01a77a1983121bab4218c39c
The first line contains two integers, n and k (1 ≤ k ≤ n ≤ 100) — the number of characters in the slogan and the initial position of the ladder, correspondingly. The next line contains the slogan as n characters written without spaces. Each character of the slogan is either a large English letter, or digit, or one of the characters: '.', '!', ',', '?'.
900
In t lines, print the actions the programmers need to make. In the i-th line print: "LEFT" (without the quotes), if the i-th action was "move the ladder to the left"; "RIGHT" (without the quotes), if the i-th action was "move the ladder to the right"; "PRINT x" (without the quotes), if the i-th action was to "go up the ladder, paint character x, go down the ladder". The painting time (variable t) must be minimum possible. If there are multiple optimal painting plans, you can print any of them.
standard output