QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#163404#7109. Traveling on the Axisawesomenick1303#WA 7ms6028kbC++20922b2023-09-04 03:19:142023-09-04 03:19:14

Judging History

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

  • [2023-09-04 03:19:14]
  • 评测
  • 测评结果:WA
  • 用时:7ms
  • 内存:6028kb
  • [2023-09-04 03:19:14]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define pb push_back
#define F first
#define S second
#define nl "\n"
#define maxn 1000005
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef pair<int,int> pii;

char s[maxn];
ll len,t1[maxn];

void solve() {
	string ssss;
	cin >> ssss;
	rep(i, 0, sz(ssss)) s[i+1] = ssss[i];
	// cin>>(s+1);
	len=strlen(s+1);
	ll ans=0;
	for(int i=1;i<=len;i++)
	{
		ll L=i,R=len-L+1;
		if(s[i]!=s[i-1]||i==1)
		{
			ans+=(L-1)*R;
			if(s[i]=='1') ans+=R;
			else ans+=2*R;
		}
		else 
		{
			ans+=2*(L-1)*R;
			if(s[i]=='1') ans+=R;
			else ans+=2*R;
		}
	}
	printf("%lld\n",ans);
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int t;
	cin >> t;
	while(t--) {
		solve();
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 4040kb

input:

3
101
011
11010

output:

12
15
43

result:

ok 3 lines

Test #2:

score: -100
Wrong Answer
time: 7ms
memory: 6028kb

input:

6107
1010101
010110100110101
1010
1010101010010101010
101011
0101101011010101010
0101101011
11011010101
010
1011010
10110101010101010100
010101010110101
10101010101011
0101010101010101011
00101010011000
1010101010010110110
01010101001010101010
101010101010101
100100101010101010
01
011
0101010100101
...

output:

96
889
843
1515
1649
1567
1567
1565
1566
1634
1702
1837
1900
1685
2193
1895
1755
1640
1768
1733
1802
1755
1755
1689
1745
1845
1839
1727
1980
1910
1640
1929
1851
1882
1926
1926
1640
1929
2003
1745
1951
1892
1759
1834
1879
1745
1745
1744
1753
2077
1790
2012
1892
1763
1790
1809
2005
2029
1932
1933
1933...

result:

wrong answer 3rd lines differ - expected: '24', found: '843'