java - 我想知道为什么该程序在 eclipse 中工作但无法在 Codejam 中提交
问题描述
我尝试参加 google code jam 和资格赛,当我提交时我得到了 WA(错误答案)。当它在我的 Eclipse 中运行良好时,我可以知道我的代码的问题,以便我可以修复我的代码。当我尝试使用示例输入和输出测试我的程序时,我也得到了正确的输出。
输入
4
3
360 480
420 540
600 660
3
0 1440
1 3
2 4
5
99 150
1 100
100 301
2 5
150 250
2
0 720
720 1440
输出
Case #1: CJC
Case #2: IMPOSSIBLE
Case #3: JCCJJ
Case #4: CC
import java.util.Scanner;
public class Solution {
public static void main(String args[]) {
int T=0;
Scanner a = new Scanner(System.in);
T = a.nextInt();
int cases=0;
String work[][] = new String[T][1000];
String data[] = new String[T];
while(T>cases) {
//System.out.println("cases: "+cases);//debug
int N=a.nextInt();
int J[][] = new int[N][2];
int C[][] = new int[N][2];
for(int i=0;i<N;i++) {
//System.out.println("For : i"+ i);//debug
int Si = a.nextInt();
int Ei = a.nextInt();
boolean check = true;
boolean check1 =true;
for(int k=0;k<i;k++) {
if(Si>=J[k][0]&&Si<J[k][1]) {
check=false;
}
if(Ei>J[k][0]&&Ei<=J[k][1]) {
check=false;
}
if(Si>=C[k][0]&&Si<C[k][1]) {
check1=false;
}
if(Ei>C[k][0]&&Ei<=C[k][1]) {
check1=false;
}
}
if(check) {
//System.out.println("Upgrade1");
J[i][0] = Si;
J[i][1] = Ei;
work[cases][i] = "J";
}else if(check1) {
//System.out.println("Upgrade2");
C[i][0] = Si;
C[i][1] = Ei;
work[cases][i] = "C";
}else
work[cases][i]= "I";
}
for(int k=0;k<N;k++) {
//System.out.println("N: "+ N);
if(k==0)
data[cases] = work[cases][k];
else
data[cases]+=work[cases][k];
}
cases++;
}
for(int k=0;k<T;k++) {
if(data[k].contains("I")) {
data[k]="Impossible";
}
}
for(int i=0;i<T;i++) {
//System.out.println("Printing");
System.out.println("Case #" + (i+1) + ": "+ data[i]);
}
}
}
解决方案
推荐阅读
- java - 在 java 字符串比较中,== 运算符和 hashcode() 方法的行为如何不同
- animation - 使用 NavigationLink isActive 时视图之间的动画不起作用
- amazon-web-services - 有没有办法检查哪个 S3 存储桶对传出数据的成本最高?
- php - docker mount 卷,但将文件保存在 docker 容器中
- html - html bootstrap 中的表格不适合屏幕
- python - 哪个值用于张量流卷积中的填充?
- python - 在pygame中上下移动矩形的问题
- postgresql - 使用下拉菜单更新 retool 中的表格内容
- javascript - 仅带实时搜索的 Bootstrap-Select
- extjs - 从另一个组件调用方法的问题