QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#156175#7109. Traveling on the Axisucup-team1004#AC ✓7ms4100kbC++14991b2023-09-02 13:18:482023-09-02 14:43:58

Judging History

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

  • [2023-09-02 14:43:58]
  • 评测
  • 测评结果:AC
  • 用时:7ms
  • 内存:4100kb
  • [2023-09-02 13:18:48]
  • 提交

answer

#include<bits/stdc++.h>
#define Gc() getchar() 
#define Me(x,y) memset(x,y,sizeof(x))
#define Mc(x,y) memcpy(x,y,sizeof(x))
#define d(x,y) ((m)*(x-1)+(y))
#define R(n) (rnd()%(n)+1)
#define Pc(x) putchar(x)
#define LB lower_bound
#define UB upper_bound
#define fi first
#define se second
using namespace std;using ll=long long;using db=double;using lb=long db;using ui=unsigned;using ull=unsigned long long;using pii=pair<int,int>;using LL=__int128;
const int N=1e5+5,M=N*20+5,K=600+5,mod=998244353,Mod=mod-1;const db eps=1e-9;const ll INF=1e18+7;mt19937 rnd(time(0));
int n,m,k;char s[N];
void init(){
	int i,j;
}
void Solve(){
	int i,j;scanf("%s",s+1);n=strlen(s+1);
	ll ans=0;
	for(i=1;i<=n;i++) ans+=1ll*i*(n-i+1);
	for(i=1;i<=n;i++) if(s[i]=='0') ans+=n-i+1;
	for(i=1;i<n;i++) if(s[i]==s[i+1]) ans+=1ll*i*(n-i);
	printf("%lld\n",ans);
}
int main(){
	int t;init();
	scanf("%d",&t);
	// t=1;
	while(t--) Solve();
	cerr<<clock()*1.0/CLOCKS_PER_SEC<<'\n';
}

这程序好像有点Bug,我给组数据试试?

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

3
101
011
11010

output:

12
15
43

result:

ok 3 lines

Test #2:

score: 0
Accepted
time: 7ms
memory: 4100kb

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
24
1515
69
1567
279
345
14
106
1702
791
621
1447
764
1615
1755
736
1333
6
15
542
44
1689
1515
140
833
497
596
24
1640
694
462
30
425
14
1041
1446
96
504
124
75
560
970
771
945
6
1
321
137
786
720
206
769
46
103
225
74
554
2
100
529
260
207
197
2
197
1041
140
857
207
1
74
1604
41
343
1041
14
1...

result:

ok 6107 lines

Extra Test:

score: 0
Extra Test Passed