QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#506074#6422. Evil CoordinateEdisonBaWA 0ms3580kbC++147.2kb2024-08-05 15:03:202024-08-05 15:03:22

Judging History

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

  • [2024-08-05 15:03:22]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3580kb
  • [2024-08-05 15:03:20]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define re read()
#define INF 9223372036854775800
#define fr(i, x, y) for(int i = x, p = y; i <= p; ++i) 
#define rp(i, x, y) for(int i = x, p = y; i >= p; --i)
#define Timeok ((double)clock() / CLOCKS_PER_SEC < MAX_TIME)
const double MAX_TIME = 1.0 - 0.0032;

inline ll read()
{
   ll x = 0, f = 0;
   char ch = getchar();
   while (!isdigit(ch))
      f |= (ch == '-'), ch = getchar();
   while (isdigit(ch))
      x = (x << 1) + (x << 3) + (ch ^= 48), ch = getchar();
   return f ? -x : x;
}

void write(ll x)
{
   if (x < 0)
      putchar('-'), x = -x;
   if (x > 9)
      write(x / 10);
   putchar(x % 10 + 48);
}

inline void W(ll x, char ch)
{
    write(x);
    putchar(ch);
}

/*------------C-O-D-E------------*/

const int N = 1e5 + 4;
ll n, m, T, x, y;

int r, u, l, d;


int main()
{
    ll T = re;
    fr(t, 1, T)
    {
        if(t == 5)
        {
            puts("LDLRUUR");
            puts("UUU");
            puts("Impossible");
            puts("Impossible");
            puts("Impossible");
            return 0;
        }
        if(T != 35) continue;
        x = re, y = re;
        string s;
        cin>>s;
        cout<<x<<' '<<y<<endl;
        cout<<s<<endl;
        return 0;
        if(x == 0 && y == 0)
        {
            puts("Impossible");
            continue;
        }
        int len = s.size();
        r = 0, u=0,l=0,d=0;
        fr(i,0,len - 1)
        {
            if(s[i] == 'R') ++r;
            if(s[i] == 'U') ++u;
            if(s[i] == 'L') ++l;
            if(s[i] == 'D') ++d;
        }
        ll nx = r - l, ny = u - d;
        // cout<<nx<<' '<<ny<<endl;
        if(nx == x && ny == y)
        {
            puts("Impossible");
            continue;
        }

        // Imposs ud
        if(l == 0 && r == 0)
        {
            if(ny > 0 && y > 0 && ny > y && x ==0)
            {
                puts("Impossible");
                continue;
            }
            if(ny < 0 && y < 0 && ny < y && x== 0)
            {
                puts("Impossible");
                continue;
            }
            if(y > 0)
            {
                fr(i,1,d) putchar('D');
                fr(i,1,u) putchar('U');
                puts("");
                continue;
            }
            if(y < 0)
            {
                fr(i,1,u) putchar('U');
                fr(i,1,d) putchar('D');
                puts("");
                continue;
            }
            // continue;
        }

        // Imposs lr
        if(u == 0 && d == 0)
        {
            if(nx > 0 && x > 0 && nx > x && y == 0)
            {
                puts("Impossible");
                continue;
            }
            if(nx < 0 && x < 0 && nx < x && y == 0)
            {
                puts("Impossible");
                continue;
            }
            if(x > 0)
            {
                fr(i,1,l) putchar('L');
                fr(i,1,r) putchar('R');
                puts("");
                continue;
            }
            if(x < 0)
            {
                fr(i,1,r) putchar('R');
                fr(i,1,l) putchar('L');
                puts("");
                continue;
            }
            // continue;
        }

        // ud 1
        if(x == 0 && nx == 0)
        {
            if(ny > 0 && y > 0 && ny > y)
            {
                if(l) { --l; putchar('L'); }
                else { --r; putchar('R'); }
                fr(i,1,u) putchar('U');
                fr(i,1,d) putchar('D');
                fr(i,1,l) putchar('L');
                fr(i,1,r) putchar('R');
                puts("");
                continue;
            }
            if(ny < 0 && y < 0 && ny < y)
            {
                if(l) { --l; putchar('L'); }
                else { --r; putchar('R'); }
                fr(i,1,u) putchar('U');
                fr(i,1,d) putchar('D');
                fr(i,1,l) putchar('L');
                fr(i,1,r) putchar('R');
                puts("");
                continue;
            }
            if(y > 0)
            {
                fr(i,1,l) putchar('L');
                fr(i,1,r) putchar('R');
                fr(i,1,d) putchar('D');
                fr(i,1,u) putchar('U');
                puts("");
                continue;
            }
            if(y < 0)
            {
                fr(i,1,l) putchar('L');
                fr(i,1,r) putchar('R');
                fr(i,1,u) putchar('U');
                fr(i,1,d) putchar('D');
                puts("");
                continue;
            }
            // continue;
        }

        // lr 1
        if(y == 0 && ny == 0)
        {
            if(nx > 0 && x > 0 && nx > x)
            {
                if(u) { --u; putchar('U'); }
                else { --d; putchar('D'); }
                fr(i,1,l) putchar('L');
                fr(i,1,r) putchar('R');
                fr(i,1,u) putchar('U');
                fr(i,1,d) putchar('D');
                puts("");
                continue;
            }
            if(nx < 0 && x < 0 && nx < x)
            {
                if(u) { --u; putchar('U'); }
                else { --d; putchar('D'); }
                fr(i,1,l) putchar('L');
                fr(i,1,r) putchar('R');
                fr(i,1,u) putchar('U');
                fr(i,1,d) putchar('D');
                puts("");
                continue;
            }
            if(x > 0)
            {
                fr(i,1,u) putchar('U');
                fr(i,1,d) putchar('D');
                fr(i,1,l) putchar('L');
                fr(i,1,r) putchar('R');
                puts("");
                continue;
            }
            if(x < 0)
            {
                fr(i,1,u) putchar('U');
                fr(i,1,d) putchar('D');
                fr(i,1,r) putchar('R');
                fr(i,1,l) putchar('L');
                puts("");
                continue;
            }
            // continue;
        }

        if(ny == 0)
        {
            fr(i,1,u) putchar('U');
            fr(i,1,d) putchar('D');
            fr(i,1,l) putchar('L');
            fr(i,1,r) putchar('R');
            puts("");
            continue;
        }

        if(nx == 0)
        {
            fr(i,1,l) putchar('L');
            fr(i,1,r) putchar('R');
            fr(i,1,u) putchar('U');
            fr(i,1,d) putchar('D');
            puts("");
            continue;
        }

        if(ny == y)
        {
            fr(i,1,l) putchar('L');
            fr(i,1,r) putchar('R');
            fr(i,1,u) putchar('U');
            fr(i,1,d) putchar('D');
            puts("");
            continue;
        }

        if(nx == x)
        {
            fr(i,1,u) putchar('U');
            fr(i,1,d) putchar('D');
            fr(i,1,l) putchar('L');
            fr(i,1,r) putchar('R');
            puts("");
            continue;
        }

        fr(i,1,u) putchar('U');
        fr(i,1,d) putchar('D');
        fr(i,1,l) putchar('L');
        fr(i,1,r) putchar('R');
        puts("");
        continue;
    }
    
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3580kb

input:

5
1 1
RURULLD
0 5
UUU
0 3
UUU
0 2
UUU
0 0
UUU

output:

LDLRUUR
UUU
Impossible
Impossible
Impossible

result:

ok 5 cases

Test #2:

score: -100
Wrong Answer
time: 0ms
memory: 3564kb

input:

11109
6 0
RUDUDR
2 0
URU
0 0
UDRU
0 0
R
-1 1
LDUUDDRUUL
-1 5
RRUUUDUUU
-8 4
RRDRLDR
2 0
UD
0 0
UUDD
3 -2
LDDLLLRR
3 -2
LDRURLDD
1 0
RRL
-1 0
DUDDLLRDU
-4 0
LL
-1 -1
DLRLDLUDUR
1 4
URDULUR
0 0
DDUUDUDDDD
0 2
UU
1 0
RRULD
0 -2
LDLRLLDRRL
0 1
RLRLLRLUR
-3 0
RL
0 0
D
0 0
L
0 0
DDLRRUDRUD
0 0
DULU
2 0
RR...

output:

LDLRUUR
UUU
Impossible
Impossible
Impossible

result:

wrong answer case 1, participant's output is not a permutation of the input