QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#128085#5078. Castle Designbatrr#WA 1ms3436kbC++173.7kb2023-07-20 15:41:482023-07-20 15:41:51

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:41:51]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3436kb
  • [2023-07-20 15:41:48]
  • 提交

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
mt19937 rnd(228);
void solve() {
    string s;
    int x = 0, y=  0;

//    int SZ = rnd() % 10 + 1;
//    s = string(SZ, 'L');
//    for (int i = 0; i < SZ; i++) {
//        if (rnd() % 2) s[i] = 'R';
//    }
//
//    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';
            reverse(s.begin(),s.end());
        }
    }
    vector<int> D(4);
    int B0 = 0;
    int W = 3;
    vector<int> QQ(4);
    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]++;
                QQ[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]++;
    }
    for (int b=0;b<2;b++)
    {
        if (QQ[b]==QQ[2+b] and QQ[b]>0 and QQ[b+1]==0 and QQ[(b+3)%4]==0 and s.length()==4)
        {
            D[b]++;
            D[b+2]++;
        }
    }
    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 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: 0
Wrong Answer
time: 1ms
memory: 3436kb

input:

LLRLLRLLRLRLLR

output:

4

result:

wrong answer 1st lines differ - expected: '16', found: '4'