import java.util.ArrayList;
import java.util.Scanner;
public class Main {
static ArrayList<Person> al = new ArrayList<>();
static int index = 0;
static int n = 0, m = 0;
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner sc = new Scanner(System.in);
n = sc.nextInt();
m = sc.nextInt();
sc.nextLine();
for (int i = 0; i < n; i++) {
Person tmp = new Person();
tmp.direction = sc.nextInt();
tmp.name = sc.nextLine();
al.add(tmp);
}
for (int i = 0; i < m; i++) {
int a = sc.nextInt();
int s = sc.nextInt();
index = count_the_index(index, a, s);
}
sc.close();
System.out.println(al.get(index).name.substring(1));
}
static class Person {
String name = "";
int direction;
}
public static int count_the_index(int person_index, int a, int s) {
Person tmp = al.get(person_index);
int direction_tmp = tmp.direction;
if ((a ^ direction_tmp) == 0) {
person_index -= s;
if (person_index < 0) {
person_index += n;
}
} else {
person_index += s;
if (person_index >= n) {
person_index -= n;
}
}
return person_index;
}
}
自己测试时两个示例全部能过,但一提交代码就报RE
编译信息
编译失败
试过把内部类写到外面来,不用异或运算符,把ArrayList改成局部变量,还把ArrayList改成了ArrayList都是报RE。 是真的没辙了。