3 条题解
-
2
C++
这道题折磨了
蒟蒻
我好久,换了三四次思路,20次WA才过。#include <bits/stdc++.h> using namespace std; char s[100]; queue <int> A, B; int main(){ for(int i = 0; i < 100; i++) { //写入 cin >> s[i]; } int n = strlen(s); for(int i = 0; i < n; i++) { //把A,B的位置存入A,B队列 if(s[i] == 'A') A.push(i); else B.push(i); } while(!A.empty() && !B.empty()) { if(A.front() < B.front()) { //找靠前的A A.push(n + A.front()); //找到后加到队列后面,方便下次查找 } else B.push(n + B.front()); //找B A.pop(); //用完就丢 B.pop(); } if(A.empty()) cout << "B"; else cout << "A"; return 0; }
信息
- ID
- 817
- 时间
- 1000ms
- 内存
- 256MiB
- 难度
- 7
- 标签
- 递交数
- 409
- 已通过
- 90
- 上传者