QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#298381#6246. مربع مارپیچmahdimalverdiAC ✓135ms57996kbJava111.9kb2024-01-06 05:21:032024-01-06 05:21:03

Judging History

你现在查看的是最新测评结果

  • [2024-01-06 05:21:03]
  • 评测
  • 测评结果:AC
  • 用时:135ms
  • 内存:57996kb
  • [2024-01-06 05:21:03]
  • 提交

answer


import java.util.Scanner;

class Codechef {    public static void main(String[] args) throws java.lang.Exception {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int s = sc.nextInt();
        int d = sc.nextInt();


        int x1 = 0, x2 =0, y1 = 0, y2 = 0;

        int counter = 0;
        for (int i = 0; i < n / 2.0; i++) {
            for (int j = i; j < n - i; j++) {
                counter++;
                if (counter == s) {
                    x1 = i;
                    y1 = j;
                }
                if (counter == d) {
                    x2 = i;
                    y2 = j;
                }
            }
            for (int j = i+1; j < n - i; j++) {
                counter++;
                if (counter == s) {
                    x1 = j;
                    y1 = n - i - 1;
                }
                if (counter == d) {
                    x2 = j;
                    y2 = n - i - 1;
                }
            }
            for (int j = n - i - 2; j > i-1; j--) {
                counter++;
                if (counter == s) {
                    x1 = n - i - 1;
                    y1 = j;
                }
                if (counter == d) {
                    x2 = n - i  - 1;
                    y2 = j;
                }
            }
            for (int j = n - i - 2; j > i; j--) {
                counter++;
                if (counter == s) {
                    x1 = j;
                    y1 = i;
                }
                if (counter == d) {
                    x2 = j;
                    y2 = i;
                }
            }
        }

        if(y1 != y2){
            System.out.printf(y1 > y2 ? "%d L\n" : "%d R\n", Math.abs(y1-y2));
        }
        if(x1 != x2){
            System.out.printf(x1 > x2 ? "%d D\n" : "%d U\n", Math.abs(x1-x2));
        }
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 90ms
memory: 55396kb

input:

5 1 25

output:

2 R
2 U

result:

ok 2 lines

Test #2:

score: 0
Accepted
time: 89ms
memory: 53580kb

input:

5 3 22

output:

3 U

result:

ok single line: '3 U'

Test #3:

score: 0
Accepted
time: 87ms
memory: 53660kb

input:

6 15 22

output:

1 R
4 D

result:

ok 2 lines

Test #4:

score: 0
Accepted
time: 112ms
memory: 55244kb

input:

1376 1845264 1658394

output:

110 L
284 U

result:

ok 2 lines

Test #5:

score: 0
Accepted
time: 112ms
memory: 57996kb

input:

868 104049 319796

output:

181 L
732 U

result:

ok 2 lines

Test #6:

score: 0
Accepted
time: 128ms
memory: 55672kb

input:

1729 1799701 863027

output:

734 R
624 U

result:

ok 2 lines

Test #7:

score: 0
Accepted
time: 112ms
memory: 55096kb

input:

1713 781627 1716559

output:

280 R
632 U

result:

ok 2 lines

Test #8:

score: 0
Accepted
time: 97ms
memory: 57060kb

input:

530 184649 257555

output:

168 R
80 U

result:

ok 2 lines

Test #9:

score: 0
Accepted
time: 135ms
memory: 55816kb

input:

1502 1494762 1733178

output:

798 R
158 D

result:

ok 2 lines

Test #10:

score: 0
Accepted
time: 132ms
memory: 57544kb

input:

1930 3293561 1087885

output:

470 L
1140 D

result:

ok 2 lines