QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#627600 | #9430. Left Shifting 2 | shiqiaqiaya# | AC ✓ | 3ms | 4416kb | C++17 | 2.2kb | 2024-10-10 16:26:55 | 2024-10-10 16:26:55 |
Judging History
answer
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/priority_queue.hpp>
#include <ext/rope>
using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;
#define int long long
using i64 = long long;
using i128 = __int128;
using f64 = double;
using f128 = long double;
constexpr i64 mod = [](bool n) { return n ? 998244353 : 1e9 + 7; } (1);
mt19937_64 rd(chrono::steady_clock::now().time_since_epoch().count());
template <class K, class C = less<>> using paring_heap = __gnu_pbds::priority_queue<K, C>;
template <class K> using rb_tree = tree<K, null_type, less<>, rb_tree_tag, tree_order_statistics_node_update>;
ostream & operator << (ostream & os, i128 t) {
string s;
for (; t; s += '0' + t % 10, t /= 10);
return reverse(s.begin(), s.end()), os << s;
}
template <class T, class ... A> void debug(T t, A ... a) { cerr << "[" << t, ((cerr << ", " << a), ...), cerr << "]\n"; }
template <i64 mod = mod> i64 binpow(i64 a, i64 b, i64 res = 1) {
for (a %= mod; b; b >>= 1, (a *= a) %= mod) {
if (b & 1) (res *= a) %= mod;
}
return res;
}
void QAQ() {
string s;cin>>s;
int n=s.length();
s=" "+s;
int ans=0;
int cnt=1;
int pos1,pos2;
for(int i=2;i<=n;i++)
{
if(s[i]==s[1]) cnt++;
else
{
pos1=i;
break;
}
if(i==n)
{
cout<<n/2<<endl;
return;
}
}
for(int i=n;i>=1;i--)
if(s[i]==s[1]) cnt++;
else
{
pos2=i;
break;
}
bool fl=0;
if(cnt%2==0)
{
fl=1;
ans+=cnt/2-1;
}
else ans+=cnt/2;
cnt=1;
for(int i=pos1;i<=pos2;i++)
{
if(i==pos1) continue;
if(s[i]==s[i-1])
{
cnt++;
if(i==pos2)
{
if(fl==0&&cnt%2==0)
ans+=cnt/2-1;
else
ans+=cnt/2;
}
}
else
{
if(fl==0&&cnt%2==0)
{
ans+=cnt/2-1;
fl=1;
}
else
{
ans+=cnt/2;
}
cnt=1;
}
}
cout<<ans<<endl;
}
signed main() {
cin.tie(0) -> sync_with_stdio(0);
int t = 1;
cin >> t;
for (cout << fixed << setprecision(12); t--; QAQ());
}
这程序好像有点Bug,我给组数据试试?
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3676kb
input:
3 abccbbbbd abcde x
output:
2 0 0
result:
ok 3 lines
Test #2:
score: 0
Accepted
time: 3ms
memory: 3616kb
input:
5000 lfpbavjsmppdppkfwnyfmbdhptdswsoulrbhyjh cfliuqnynejgnxolzbdoztclzbozqomvioszk eiivcoqoymonrqgrjdtkts mdcvservaxcbioopfungsgkiftchwlmtbzqgaraovjknsgiegkvdbolmeunvrxrpscnf ujeqtidwtoikkqtygo llma qjfvgwrdhaazejsfgilnpmmhkefndzvyon kzwwpdpbrudqmwmjscllnnjyoepxophcoopvfepikouinuxx vftculoorxskpkxoz...
output:
1 0 0 0 0 0 1 4 0 0 1 1 1 1 1 3 1 0 5 6 0 0 5 2 0 1 3 2 0 3 0 1 0 1 1 0 1 4 1 3 1 0 1 5 3 0 3 0 0 1 8 1 0 6 1 2 0 1 0 0 4 1 2 4 3 1 3 2 3 1 2 1 0 0 2 0 2 2 0 4 0 5 5 0 3 0 4 1 0 2 1 0 2 0 1 6 1 2 1 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 3 3 3 1 2 0 1 1 4 3 1 3 1 1 1 2 0 1 2 0 4 0 1 1 ...
result:
ok 5000 lines
Test #3:
score: 0
Accepted
time: 2ms
memory: 4252kb
input:
1 cbppzfsncqyzmuwrcvtxsciucxusskcjhaanwhqmyncytwhkubrvcqxgcehdxyewdyvpqjcmrnmlgrytrucexmmfulqbtfctehphmrzkosyvhtvjrromqncbgsjcwhmlqidkycaxyhsrduoxayntuhqubvboseeziwjvrfagsbvtxjjbexnajqapgxydwtztzbbdpoydnjipfizdfpmczgqvdmpvxbqubtygkfpdeonegfzsttirbhzkobbigwneyvtcxndfkljdvbbcfnadtfhgohfzqeidtgyandhnvb...
output:
18631
result:
ok single line: '18631'
Test #4:
score: 0
Accepted
time: 0ms
memory: 4416kb
input:
1 qokalgqjhyijyizyihdsiapbgvzxzevykavqmgqzrpjngciqcljsuplvpaziebmumatzvngwrhgsxrtcoiseihejwpewvosnrgvhoxluliuwixgxylazufebrwgfebazrkghgwbpqavehtnakmzqsetghmzoydwmeqvoplkyqngwrgktylrnaojpkvuwfsjbizedqwhfteyjobrglkhkeoxmxdgyuygawvdjhyakpkjchyxaqthrglcldevrzskdaotkbsbmnstrsxervdvmaylqxnwaecfmdszwedrdom...
output:
0
result:
ok single line: '0'
Test #5:
score: 0
Accepted
time: 2ms
memory: 4252kb
input:
1 bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbyyqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhcccccccccccccccccccccccccccccccccccccccccccccccccccccccccccceeeeeeeeeeeeeeeeeeeeezzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz...
output:
246800
result:
ok single line: '246800'
Test #6:
score: 0
Accepted
time: 2ms
memory: 4336kb
input:
1 yyyyyyyyyyyyyyyyyyyyyyyyhhhhhhhhaaaannnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnhhhhhhhhhhhhhhhhhhhhhhhiiiiiiiieeeeeeeeeesssssssbbbbbbbbbbiiiiiiiwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxaaaaaaaaaaaaaaaadccccckkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkc...
output:
242729
result:
ok single line: '242729'
Extra Test:
score: 0
Extra Test Passed