QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#128059#5078. Castle Designbatrr#WA 2ms3624kbC++173.2kb2023-07-20 15:16:042023-07-20 15:16:05

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-07-20 15:16:05]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:3624kb
  • [2023-07-20 15:16:04]
  • 提交

answer

#include <bits/stdc++.h>

#define f first
#define s second
#define pb push_back
#define mp make_pair

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;

const int N = 4300500, inf = 1e9;
const ll mod = 998244353;
const ll INF = 1e18;

int sum(int a, int b) {
    a += b;
    if (a >= mod)
        a -= mod;
    return a;
}

int sub(int a, int b) {
    a -= b;
    if (a < 0)
        a += mod;
    return a;
}

int mult(int a, int b) {
    return 1ll * a * b % mod;
}

int bp(int a, int b) {
    int res = 1;
    while (b) {
        if (b & 1)
            res = mult(res, a);
        a = mult(a, a);
        b >>= 1;
    }
    return res;
}

int inv(int x) {
    return bp(x, mod - 2);
}



#define X first
#define Y second

void solve() {
    string s;
    cin >> s;
    int n = s.length();
    {
        int q = 0;
        for (int i=0;i<n;i++)
        {
            if (s[i]=='L') q++;
        }
        if (q!=(n-4)/2+4)
        {
            for (int i=0;i<n;i++) s[i] ^= 'L'^'R';
        }
    }
    vector<int> D(4);
    int B0 = 0;
    int W = 3;
    while (W--)
    {
        string s2;
        int B = B0;
        for (int i=0;i<n;i++)
        {
            if (i+2<n and s[i]=='L' and s[i+1]=='R' and s[i+2]=='L')
            {
                s2 += 'L';
                D[B]++;
                B = (B+1)%4;
                D[B]++;
                i = i+2;
                continue;
            }
            s2 += s[i];
            if (s[i]=='L') B = (B+1)%4;
            else B = (B+3)%4;
        }
        s = s2;
        if (s.length()!=n) n = s.length(), W = 3;
        else
        {
            if (s[0]=='L') B0 = (B0+1)%4;
            else B0 = (B0+3)%4;
            s = "";
            for (int j=0;j<n;j++) s += s2[(j+1)%n];
        }
    }
    //cout << s << endl;
    {
        D[0]++, D[1]++, D[2]++, D[3]++;
    }
    int B = B0;
    int st = 0;
    for (int i=0;i<n;i++)
    {
        if (s[i]=='L' and s[i+1]=='R')
        {
            st = i;
            break;
        }
        if (s[i]=='L') B = (B+1)%4;
        else B = (B+3)%4;
    }
    vector<int> D2(4);
    for (int i=0;i<n;i++)
    {
        int p = (i+st)%n;
        if (s[p]=='L' and s[(p+1)%n]=='R')
        {
            D2[B]++;
            i += 3;
            continue;
        }
        B = (B+1)%4;
    }
    for (int b=0;b<4;b++)
    {
        if (D2[b]>0)
        {
            int Q = 1;
            if (D2[b^2]>0) Q = 2;
            if (Q==1 or (Q==2 and b<2)) D[(b+1)%4] = max(D[(b+1)%4],Q+1), D[(b+3)%4] = max(D[(b+3)%4],Q+1);
        }
    }
    for (int b=0;b<4;b++)
    {
        D[(b+1)%4] += D2[b];
        D[(b+3)%4] += D2[b];
        D[b] += D2[b]*2;
    }
    int A = 0;
    //for (int i=0;i<4;i++) cout << D[i] << " ";
    for (int i=0;i<2;i++) A += max(D[i],D[i+2])*2;
    cout << A << "\n";
}

int main() {
#ifdef DEBUG
    freopen("input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false);
    int t = 1;
//    cin >> t;
    for (int i = 1; i <= t; i++) {
//        cout << "Case #" << i << endl;
        solve();
    }
}

詳細信息

Test #1:

score: 100
Accepted
time: 1ms
memory: 3488kb

input:

LLRLLRLLRLRLLR

output:

16

result:

ok single line: '16'

Test #2:

score: 0
Accepted
time: 1ms
memory: 3484kb

input:

RLLRLLLRRLLRLRLL

output:

20

result:

ok single line: '20'

Test #3:

score: 0
Accepted
time: 1ms
memory: 3448kb

input:

LLRRLLLLRRLL

output:

16

result:

ok single line: '16'

Test #4:

score: 0
Accepted
time: 1ms
memory: 3508kb

input:

RLLRLLRLLRLL

output:

12

result:

ok single line: '12'

Test #5:

score: 0
Accepted
time: 0ms
memory: 3592kb

input:

LRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLR...

output:

199996

result:

ok single line: '199996'

Test #6:

score: 0
Accepted
time: 2ms
memory: 3568kb

input:

LRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLR...

output:

155164

result:

ok single line: '155164'

Test #7:

score: 0
Accepted
time: 2ms
memory: 3620kb

input:

LRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLR...

output:

189748

result:

ok single line: '189748'

Test #8:

score: 0
Accepted
time: 2ms
memory: 3592kb

input:

LRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLR...

output:

137900

result:

ok single line: '137900'

Test #9:

score: -100
Wrong Answer
time: 1ms
memory: 3624kb

input:

LRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLRLR...

output:

100000

result:

wrong answer 1st lines differ - expected: '100002', found: '100000'