QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#407627#6422. Evil CoordinateChongQYCompile Error//C++149.3kb2024-05-09 08:10:082024-05-09 08:10:08

Judging History

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

  • [2024-05-09 08:10:08]
  • 评测
  • [2024-05-09 08:10:08]
  • 提交

answer

import com.sun.source.tree.Tree;

import java.io.*;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.*;

public class Main {
    public static Read scanner = new Read(System.in);
    public static final long MOD = (long) (1e9 + 7);
    public static final int MID = (int) (4 * 1e6 + 7);
    public static final long LMAX = Long.MAX_VALUE;
    public static final long LMIN = Long.MIN_VALUE;
    public static final int IMAX = Integer.MAX_VALUE;
    public static final int IMIN = Integer.MIN_VALUE;
    public static int[] arr = new int[MID];
    //    public static long[] Qz = new long[MID];
//    public static long[] Hz = new long[MID];
    public static int N, M , n , m;
    public static long ans;
    //    public static boolean[][] stack = new boolean[MID][MID];
    //四个方向
    public static int[] row = {1, -1, 0, 0};
    public static int[] cos = {0, 0, 1, -1};
    static PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
    public static int p = (int)(2e6);
    public static void solve(){
        int my = scanner.nextInt();
        int mx = scanner.nextInt();
        String str = scanner.nextLine();n = str.length();
        int l = 0;
        int r = 0;
        int u = 0;
        int d = 0;
        int inx = 0;
        int iny = 0;
        for(int i = 0 ; i < n ; i++){
            char ch = str.charAt(i);
            if(ch == 'L') {
                l++;
                inx--;
            } else if(ch == 'R') {
                r++;
                inx++;
            } else if(ch == 'D') {
                d++;
                iny--;
            } else {
                u++;
                iny++;
            }
        }
        //特判
        if(l > 0 && r == 0 && u == 0 && d == 0 && (l >= -mx && my == 0)) {out.println("Impossible");return;}
        if(l > 0 && r == 0 && u == 0 && d == 0) {out.println(str);return;}
        if(r > 0 && l == 0 && u == 0 && d == 0 && (r >= mx && my == 0)) {out.println("Impossible");return;}
        if(r > 0 && l == 0 && u == 0 && d == 0) {out.println(str);return;}
        if(u > 0 && l == 0 && r == 0 && d == 0 && (u >= my && mx == 0)) {out.println("Impossible");return;}
        if(u > 0 && l == 0 && r == 0 && d == 0) {out.println(str);return;}
        if(d > 0 && l == 0 && r == 0 && u == 0 && (d >= -my && mx == 0)) {out.println("Impossible");return;}
        if(d > 0 && l == 0 && r == 0 && u == 0) {out.println(str);return;}
        if(mx == 0 && my == 0) {out.println("Impossible");return;}
        if(inx == mx && iny == my) {out.println("Impossible");return;}

        //有正解..

        StringBuilder ans = new StringBuilder();
        //消 横纵
        while(l > 0 && r > 0){
            if(mx == -1 && my == 0){
                ans.append("RL");
            } else {
                ans.append("LR");
            }
            l--;r--;
        }
        while(u > 0 && d > 0){
            if(mx == 0 && my == -1){
                ans.append("UD");
            } else {
                ans.append("DU");
            }
            u--;d--;
        }

        //找路
        if(l > 0 && u > 0){//左上
            if((my == 0 && -mx <= l) || (-mx == l && my <= u)){
                while(u-- != 0){
                    ans.append("U");
                }
                while(l-- != 0){
                    ans.append("L");
                }
            } else {
                while(l-- != 0){
                    ans.append("L");
                }
                while(u-- != 0){
                    ans.append("U");
                }
            }
        } else if(l > 0 && d > 0){//左下
            if((my == 0 && -mx <= l) || (-mx == l && -my <= u)){
                while(d-- != 0){
                    ans.append("D");
                }
                while(l-- != 0){
                    ans.append("L");
                }
            } else {
                while(l-- != 0){
                    ans.append("L");
                }
                while(d-- != 0){
                    ans.append("D");
                }
            }
        } else if(r > 0 && u > 0){//右上
            if((my == 0 && mx <= r) || (mx == r && my <= u)){
                while(u -- != 0){
                    ans.append("U");
                }
                while(r -- != 0){
                    ans.append("R");
                }
            } else {
                while(r -- != 0){
                    ans.append("R");
                }
                while(u -- != 0){
                    ans.append("U");
                }
            }
        } else if(r > 0 && d > 0){//右下
            //
            if((my == 0 && mx <= r) || (mx == r && -my <= u)){
                while(d -- != 0){
                    ans.append("D");
                }
                while(r -- != 0){
                    ans.append("R");
                }
            } else {
                while(r -- != 0){
                    ans.append("R");
                }
                while(d -- != 0){
                    ans.append("D");
                }
            }
        }
        if(l > 0 && r == 0 && u == 0 && d == 0 && (l >= -mx && my == 0)){
            int index = 0;
            while(!(ans.charAt(index) == 'U' || ans.charAt(index) == 'D')) index++;
            char ch = ans.charAt(index);
            ans.delete(index , index + 1);
            while(l-- != 0) ans.append("L");
            ans.append(ch);
        } else if(l > 0 && r == 0 && u == 0 && d == 0){
            while(l-- != 0) ans.append("L");
        }

        if(r > 0 && l == 0 && u == 0 && d == 0 && (r >= mx && my == 0)){
            int index = 0;
            while(!(ans.charAt(index) == 'U' || ans.charAt(index) == 'D')) index++;
            char ch = ans.charAt(index);
            ans.delete(index , index + 1);
            while(r-- != 0) ans.append("R");
            ans.append(ch);
        } else if(r > 0 && l == 0 && u == 0 && d == 0){
            while(r-- != 0) ans.append("R");
        }

        if(l == 0 && r == 0 && u > 0 && d == 0 && (u >= my && mx == 0)){
            int index = 0;
            while(!(ans.charAt(index) == 'L' || ans.charAt(index) == 'R')) index++;
            char ch = ans.charAt(index);
            ans.delete(index , index + 1);
            while(u-- != 0) ans.append("U");
            ans.append(ch);
        } else if(l == 0 && r == 0 && u > 0 && d == 0){
            while(u-- != 0) ans.append("U");
        }

        if(l == 0 && r == 0 && u == 0 && d > 0 && (d >= -my && mx == 0)){
            int index = 0;
            while(!(ans.charAt(index) == 'L' || ans.charAt(index) == 'R')) index++;
            char ch = ans.charAt(index);
            ans.delete(index , index + 1);
            while(d-- != 0) ans.append("D");
            ans.append(ch);
        } else  if(l == 0 && r == 0 && u == 0 && d > 0){
            while(d-- != 0) ans.append("D");
        }
        System.out.println(ans);

    }
    public static void main(String[] args) {

//        long start = System.currentTimeMillis();//程序开始时间戳
        int T = scanner.nextInt();
        while (T-- != 0) {
            solve();
        }
        out.flush();
//        long end = System.currentTimeMillis();//程序结束时间戳
//        out.println("运行时间 : " + (end - start));//输出运行时间
    }
    //快读
    static class Read {
        BufferedReader br;
        StringTokenizer st;

        public Read(InputStream in) {
            br = new BufferedReader(new InputStreamReader(in), 16384);
            eat("");
        }

        public void eat(String s) {
            st = new StringTokenizer(s);
        }

        public String nextLine() {
            try {
                return br.readLine();
            } catch (IOException e) {
                return null;
            }
        }

        public boolean hasNext() {
            while (!st.hasMoreTokens()) {
                String s = nextLine();
                if (s == null)
                    return false;
                eat(s);
            }
            return true;
        }

        public String next() {
            hasNext();
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public Double nextDouble() {
            return Double.parseDouble(next());
        }

        public BigInteger nextBigInteger() {
            return new BigInteger(next());
        }

        public BigDecimal nextBigDecimal() {
            return new BigDecimal(next());
        }
    }
    public static void swap(long[] arr , int index1 , int index2){
        long t = arr[index1];
        arr[index1] = arr[index2];
        arr[index2] = t;
    }
    public static long Dot_pitch(long x , long y , long xx , long yy){
        return (xx - x) * (xx - x) + (yy - y) * (yy - y);
//        return (long) Math.sqrt(Math.pow(xx - x , 2) + Math.pow(yy - y , 2));
    }
}

class way {
    public int jd , b;

    public way(int jd, int b) {
        this.jd = jd;
        this.b = b;
    }
}

Details

answer.code:1:1: error: ‘import’ does not name a type
    1 | import com.sun.source.tree.Tree;
      | ^~~~~~
answer.code:1:1: note: C++20 ‘import’ only available with ‘-fmodules-ts’
answer.code:3:1: error: ‘import’ does not name a type
    3 | import java.io.*;
      | ^~~~~~
answer.code:3:1: note: C++20 ‘import’ only available with ‘-fmodules-ts’
answer.code:4:1: error: ‘import’ does not name a type
    4 | import java.math.BigDecimal;
      | ^~~~~~
answer.code:4:1: note: C++20 ‘import’ only available with ‘-fmodules-ts’
answer.code:5:1: error: ‘import’ does not name a type
    5 | import java.math.BigInteger;
      | ^~~~~~
answer.code:5:1: note: C++20 ‘import’ only available with ‘-fmodules-ts’
answer.code:6:1: error: ‘import’ does not name a type
    6 | import java.util.*;
      | ^~~~~~
answer.code:6:1: note: C++20 ‘import’ only available with ‘-fmodules-ts’
answer.code:8:1: error: expected unqualified-id before ‘public’
    8 | public class Main {
      | ^~~~~~
answer.code:279:11: error: expected ‘:’ before ‘int’
  279 |     public int jd , b;
      |           ^~~~
      |           :
answer.code:281:11: error: expected ‘:’ before ‘way’
  281 |     public way(int jd, int b) {
      |           ^~~~
      |           :
answer.code:285:2: error: expected ‘;’ after class definition
  285 | }
      |  ^
      |  ;
answer.code: In constructor ‘way::way(int, int)’:
answer.code:282:14: error: request for member ‘jd’ in ‘(way*)this’, which is of pointer type ‘way*’ (maybe you meant to use ‘->’ ?)
  282 |         this.jd = jd;
      |              ^~
answer.code:283:14: error: request for member ‘b’ in ‘(way*)this’, which is of pointer type ‘way*’ (maybe you meant to use ‘->’ ?)
  283 |         this.b = b;
      |              ^