meituan-004. 小团的复制粘贴
This commit is contained in:
parent
de249f462a
commit
d6c979e526
@ -1,7 +1,7 @@
|
|||||||
package study.plan.meituan;
|
package study.plan.meituan;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.util.*;
|
import java.util.StringTokenizer;
|
||||||
|
|
||||||
public class Solution {
|
public class Solution {
|
||||||
|
|
||||||
@ -15,39 +15,7 @@ public class Solution {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void solve() throws IOException {
|
public static void solve() throws IOException {
|
||||||
int T = sc.nextInt();
|
|
||||||
while(T-- > 0){
|
|
||||||
String s = sc.next();
|
|
||||||
if(s.length() == 0){
|
|
||||||
pw.println("Wrong");
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if(!Character.isLetter(s.charAt(0))){
|
|
||||||
pw.println("Wrong");
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
boolean flag = true;
|
|
||||||
boolean hasLetter = false;
|
|
||||||
boolean hasDigit = false;
|
|
||||||
for (int i = 0; i < s.length(); i++) {
|
|
||||||
if(!(Character.isLetter(s.charAt(i)) || Character.isDigit(s.charAt(i)))){
|
|
||||||
flag = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if(Character.isLetter(s.charAt(i))){
|
|
||||||
hasLetter = true;
|
|
||||||
}
|
|
||||||
if(Character.isDigit(s.charAt(i))){
|
|
||||||
hasDigit = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(flag && hasLetter && hasDigit){
|
|
||||||
pw.println("Accept");
|
|
||||||
}else{
|
|
||||||
pw.println("Wrong");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
92
src/main/java/study/plan/meituan/meituan004/Solution.java
Normal file
92
src/main/java/study/plan/meituan/meituan004/Solution.java
Normal file
@ -0,0 +1,92 @@
|
|||||||
|
package study.plan.meituan.meituan004;
|
||||||
|
|
||||||
|
import java.io.*;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.StringTokenizer;
|
||||||
|
|
||||||
|
public class Solution {
|
||||||
|
|
||||||
|
static Scanner sc;
|
||||||
|
static PrintWriter pw;
|
||||||
|
|
||||||
|
public static void main(String[] args) throws IOException {
|
||||||
|
sc = new Scanner(System.in);
|
||||||
|
pw = new PrintWriter(System.out);
|
||||||
|
solve();
|
||||||
|
pw.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void solve() throws IOException {
|
||||||
|
int length = sc.nextInt();
|
||||||
|
int[] bArr = new int[length];
|
||||||
|
Arrays.fill(bArr, -1);
|
||||||
|
int[] aArr = sc.nextIntArr(length);
|
||||||
|
int num = sc.nextInt();
|
||||||
|
List<Integer> list = new ArrayList<>();
|
||||||
|
for (int i = 0; i < num; i++) {
|
||||||
|
int op = Integer.parseInt(sc.next());
|
||||||
|
if (op == 2) {
|
||||||
|
list.add(bArr[Integer.parseInt(sc.next()) - 1]);
|
||||||
|
} else {
|
||||||
|
int k = Integer.parseInt(sc.next());
|
||||||
|
int x = Integer.parseInt(sc.next()) - 1;
|
||||||
|
int y = Integer.parseInt(sc.next()) - 1;
|
||||||
|
// System.arraycopy(aArr, x, bArr, y, k);
|
||||||
|
for (int j = 0; j < k; j++) {
|
||||||
|
if (y >= bArr.length || x >= aArr.length) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
bArr[y] = aArr[x];
|
||||||
|
x++;
|
||||||
|
y++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (Integer integer : list) {
|
||||||
|
pw.println(integer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static class Scanner {
|
||||||
|
BufferedReader br;
|
||||||
|
StringTokenizer st;
|
||||||
|
|
||||||
|
public Scanner(InputStream s) {
|
||||||
|
br = new BufferedReader(new InputStreamReader(s));
|
||||||
|
}
|
||||||
|
|
||||||
|
public Scanner(FileReader f) {
|
||||||
|
br = new BufferedReader(f);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String next() throws IOException {
|
||||||
|
while (st == null || !st.hasMoreTokens())
|
||||||
|
st = new StringTokenizer(br.readLine());
|
||||||
|
return st.nextToken();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int nextInt() throws IOException {
|
||||||
|
return Integer.parseInt(next());
|
||||||
|
}
|
||||||
|
|
||||||
|
public long nextLong() throws IOException {
|
||||||
|
return Long.parseLong(next());
|
||||||
|
}
|
||||||
|
|
||||||
|
public double nextDouble() throws IOException {
|
||||||
|
return Double.parseDouble(next());
|
||||||
|
}
|
||||||
|
|
||||||
|
public int[] nextIntArr(int n) throws IOException {
|
||||||
|
int[] arr = new int[n];
|
||||||
|
for (int i = 0; i < n; i++) {
|
||||||
|
arr[i] = Integer.parseInt(next());
|
||||||
|
}
|
||||||
|
return arr;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user