QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#697982#9430. Left Shifting 2Miguel03121WA 2ms3844kbC++17884b2024-11-01 16:43:092024-11-01 16:43:10

Judging History

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

  • [2024-11-01 16:43:10]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:3844kb
  • [2024-11-01 16:43:09]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

#define F(i, a, b) for (int i = a; i < b; i++)
#define ALL(x) x.begin(), x.end()
#define IOS ios_base::sync_with_stdio(0)

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef long long ll;

int main() {
  IOS;
  cin.tie(0), cout.tie(0);

  string s;
  int t;
  cin >> t;
  while (t--) {
    cin >> s;
    int n = s.size(), base = 0;
    int cnt = 1;
    F(i, 0, n) {
      if (i != n - 1 && s[i] == s[i + 1]) {
        cnt++;
      } else {
        if (cnt % 2 == 0) {
          base = i;
          break;
        }
        cnt = 1;
      }
    }
    int ans = 0;
    F(i, 0, n - 1) {
      if (base + i != n - 1 && s[(base + i) % n] == s[(base + i + 1) % n]) {
        ans++, i++;
      }
    }
    cout << ans << '\n';
  }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

3
abccbbbbd
abcde
x

output:

2
0
0

result:

ok 3 lines

Test #2:

score: -100
Wrong Answer
time: 2ms
memory: 3580kb

input:

5000
lfpbavjsmppdppkfwnyfmbdhptdswsoulrbhyjh
cfliuqnynejgnxolzbdoztclzbozqomvioszk
eiivcoqoymonrqgrjdtkts
mdcvservaxcbioopfungsgkiftchwlmtbzqgaraovjknsgiegkvdbolmeunvrxrpscnf
ujeqtidwtoikkqtygo
llma
qjfvgwrdhaazejsfgilnpmmhkefndzvyon
kzwwpdpbrudqmwmjscllnnjyoepxophcoopvfepikouinuxx
vftculoorxskpkxoz...

output:

1
0
0
0
0
0
1
4
0
0
1
1
0
1
1
3
0
0
5
6
0
0
5
2
0
1
3
1
0
3
0
1
0
1
1
0
1
4
1
3
1
0
1
5
3
0
3
0
0
1
7
0
0
6
1
2
0
1
0
0
4
1
2
4
3
1
3
2
3
0
2
0
0
0
2
0
2
2
0
4
0
5
5
0
3
0
4
0
0
2
1
0
2
0
1
6
1
2
0
3
3
3
5
2
3
0
3
5
1
3
0
0
3
0
4
5
3
2
1
1
0
0
2
0
1
1
2
3
3
1
2
0
1
1
4
2
1
3
0
1
1
2
0
1
2
0
4
0
1
1
...

result:

wrong answer 13th lines differ - expected: '1', found: '0'