Task: | Spiraali |
Sender: | valk |
Submission time: | 2021-10-13 23:35:17 +0300 |
Language: | Java |
Status: | READY |
Result: | 0 |
group | verdict | score |
---|---|---|
#1 | WRONG ANSWER | 0 |
#2 | WRONG ANSWER | 0 |
#3 | TIME LIMIT EXCEEDED | 0 |
test | verdict | time | group | |
---|---|---|---|---|
#1 | WRONG ANSWER | 0.27 s | 1 | details |
#2 | WRONG ANSWER | 0.42 s | 2 | details |
#3 | TIME LIMIT EXCEEDED | -- | 3 | details |
Code
import java.util.HashMap; import java.util.Map.Entry; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner input = new Scanner(System.in); int size = input.nextInt(); //size int tests = input.nextInt(); //tests for(int i = 0; i < tests; i++) { int y = input.nextInt(); int x = input.nextInt(); int layer = 0; if(x > y && y <= size/2) { layer = y; } else if(x <= size/2){ layer = x; } else if (x > y) { layer = x; }else { layer = y; } System.out.println(" layer before fix " + layer); if(layer > size/2) layer = size/2-(layer-size/2)+1; int width = (size-(layer-1)*2); System.out.println("width " + width + " layer " + layer); int result = 0; int tArea = 0; for(int l = 0+1; l < layer; l++) { tArea += (size-(layer-1-l)*2)*4-4; } System.out.println("full area: " + tArea); System.out.println("lx " + layer); System.out.println("rx " + (size-layer+1)); System.out.println("ty " + layer); System.out.println("by " + (size-layer+1)); if(x == layer) { //left d tArea += width; tArea -= width-(y-(layer-1)); System.out.println("left"); }else if(x == size-layer+1 && x != y) {//right d tArea += width*3-1; if(y == layer) tArea -= layer-1; tArea -= y-(layer-1)*2; System.out.println("right"); }else if(y == layer) {//top d tArea += width*4-2; tArea -= x-(layer-1)*2; System.out.println("top"); }else if(y == size-layer+1) {//bottom d tArea -= width-(x-(layer-1)); tArea += width*2-1; System.out.println("bottom"); } //current layer = lower of x or y //layer width = (size-(layer-1)*2) //layer area = (size-(layer-1)*2)*4-4 //go through earlier spirals to get total //then remove extra that hasnt been reached yet System.out.println(tArea); } input.close(); } }
Test details
Test 1
Group: 1
Verdict: WRONG ANSWER
input |
---|
10 100 1 1 1 2 1 3 1 4 ... |
correct output |
---|
1 36 35 34 33 ... |
user output |
---|
layer before fix 1 width 10 layer 1 full area: 0 lx 1 rx 10 ... Truncated |
Test 2
Group: 2
Verdict: WRONG ANSWER
input |
---|
1000 1000 371 263 915 322 946 880 53 738 ... |
correct output |
---|
773533 312166 206053 200080 593922 ... |
user output |
---|
layer before fix 263 width 476 layer 263 full area: 773424 lx 263 rx 738 ... Truncated |
Test 3
Group: 3
Verdict: TIME LIMIT EXCEEDED
input |
---|
1000000000 1000 177757853 827347032 409613589 419171337 739269360 256524697 328695530 896842209 ... |
correct output |
---|
571375684522141210 967321186816598569 762879105851175000 370065046779516790 936897883750373771 ... |
user output |
---|
(empty) |