QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#847136#9925. LR Stringucup-team073#WA 164ms3800kbC++203.3kb2025-01-07 17:45:052025-01-07 17:45:05

Judging History

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

  • [2025-01-07 17:45:05]
  • 评测
  • 测评结果:WA
  • 用时:164ms
  • 内存:3800kb
  • [2025-01-07 17:45:05]
  • 提交

answer

#include<bits/stdc++.h>
#ifdef LOCAL
#define debug(...) printf(__VA_ARGS__)
#define edebug(...) fprintf(stderr, __VA_ARGS__)
#else
#define debug(...)
#define edebug(...)
#endif
#define int ll
#define rep(i, x, y) for(int i = x; i <= y; ++i)
#define nrep(i, x, y) for(int i = x; i >= y; --i)
#define ll long long
#define pii std::pair<int,int>
#define pb emplace_back
#define fi first
#define se second
template <class T> 
inline void ckmax(T &a, T b) {
  if(a < b) a = b;
}
template <class T> 
inline void ckmin(T &a, T b) {
  if(a > b) a = b;
}
auto rt_YES = []{puts("YES");};
auto rt_Yes = []{puts("Yes");};
auto rt_NO = []{puts("NO");};
auto rt_No = []{puts("No");};
namespace IO {
#define isdigit(x) (x >= '0' && x <= '9')
  inline char gc() {
    return getchar();
  }
  inline bool blank(char ch) {
    return ch == ' ' || ch == '\n' || ch == '\r' || ch == '\t';
  }
  template <class T>
  inline void read(T &x) {
    double tmp = 1;
    bool sign = 0;
    x = 0;
    char ch = gc();
    for(; !isdigit(ch); ch = gc())
      if(ch == '-') sign = 1;
    for(; isdigit(ch); ch = gc())
      x = x * 10 + (ch - '0');
    if(ch == '.')
      for(ch = gc(); isdigit(ch); ch = gc())
        tmp /= 10.0, x += tmp * (ch - '0');
    if(sign) x = -x;
  }
  inline void read(char *s) {
    char ch = gc();
    for(; blank(ch); ch = gc());
    for(; !blank(ch); ch = gc())
      *s++ = ch;
    *s = 0;
  }
  inline void read(char &c) {
    for(c = gc(); blank(c); c = gc());
  }
  inline void push(const char &c) {
    putchar(c);
  }
  template <class T>
  inline void print(T x) {
    if(x < 0) {
      x = -x;
      push('-');
    }
    static T sta[35];
    T top = 0;
    do {
      sta[top++] = x % 10;
      x /= 10;
    } while(x);
    while(top)
      push(sta[--top] + '0');
  }
  template <class T>
  inline void print(T x, char lastChar) {
    print(x);
    push(lastChar);
  }
}
using namespace IO;

std::string s;
std::vector<int>A;
void solve(){
  std::cin>>s;int q;read(q);
  A.clear();
  int n=s.size();
  if(s[0]!='L')A.pb(0);
  rep(i,0,n-1){
    if(i==0||s[i]!=s[i-1])A.pb(1);
    else{
      int T=A.back();A.pop_back();++T;A.pb(T);
    }
  }
  // for(int i:A)print(i,' ');
  // puts("");
  rep(i,1,q){
    std::vector<int>B;
    std::string t;std::cin>>t;
    if(t[0]!='L')B.pb(0);
    int N=t.size();
    rep(j,0,N-1){
      if(j==0||t[j]!=t[j-1])B.pb(1);
      else{
        int T=B.back();B.pop_back();++T;B.pb(T);
      }
    }
    // for(int i:B)print(i,' ');
    // puts("");
    int cntA=A.size(),cntB=B.size(),cur=0;
    int flag=1;
    rep(j,0,cntB-1){
      int sum=0;
      while(cur<cntA&&sum<B[j]){
        sum+=A[cur];
        if(sum>=B[j]){++cur;break;}
        else cur+=2;
      }
      if(sum==0)++cur;
      // debug("%lld %lld\n",j,cur);
      if(sum<B[j]){flag=0;break;}
      if(cur>cntA){flag=0;break;}
    }
    if(flag){rt_YES();}
    else rt_NO();
  }
}

signed main() {
  clock_t c1 = clock();
#ifdef LOCAL
  freopen("in.in", "r", stdin);
  freopen("out.out", "w", stdout);
#endif
//------------------------------------------------------------------

  int t;read(t);while(t--)solve();

//------------------------------------------------------------------
end:
  std::cerr << "Time : " << clock() - c1 << " ms" << std::endl;
  return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

2
RRLLRRLL
4
LLLLL
LLR
LRLR
R
RLLLLLL
3
LLLLL
RL
RRL

output:

NO
YES
NO
YES
YES
YES
NO

result:

ok 7 lines

Test #2:

score: -100
Wrong Answer
time: 164ms
memory: 3800kb

input:

100000
RRLLR
4
R
R
R
R
LRLLL
6
R
L
L
L
L
R
RLLRR
1
L
LRLLL
3
R
L
L
RLRRL
2
LRRRR
RRRL
LRLRR
2
L
R
RRLRL
4
RLRLR
RLLL
LR
RLL
RLRLL
8
R
R
R
L
L
L
R
L
RLLRR
7
R
LL
RL
R
L
L
L
LLRLR
2
L
R
RRRRL
1
RLLLR
RRLLL
2
L
L
RLLRL
1
RLLRL
LRLLL
5
RLRLL
RLLLR
RRRRL
LLRRR
RLLRR
LRLLL
3
RRLL
R
RL
LLRRL
3
L
R
LLLRR
RR...

output:

YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
NO
YES
YES
YES
NO
NO
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
NO
YES
YES
YES
NO
NO
NO
NO
NO
NO
YES
YES
YES
YES
NO
NO
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
YES
NO
YES
YES
YES
N...

result:

wrong answer 5th lines differ - expected: 'NO', found: 'YES'