QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#482854#7109. Traveling on the AxiscloudsssWA 148ms4872kbC++201.4kb2024-07-17 22:46:212024-07-17 22:46:21

Judging History

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

  • [2024-07-17 22:46:21]
  • 评测
  • 测评结果:WA
  • 用时:148ms
  • 内存:4872kb
  • [2024-07-17 22:46:21]
  • 提交

answer

#include<iostream>
#include<algorithm>
#include<cstring>
#include<string>
#include<cstdio>
#include<vector>
typedef long long LL;
using namespace std;
int main()
{
    int t;
    cin>>t;
    while(t--)
    {
        string s1,s2;
        cin>>s1;
        int time[100010]={0};
        LL sum[100010]= {0};
        LL ans=0;
        for(int i=0; i<s1.size(); i++)
        {
            s2[i]=(s1[i]=='1')?'0':'1';
            if(s1[i]=='0')
                time[i]=2;
            else
                time[i]=1;
        }
        int flag=1;
        LL res=0;
        for(int i=0; i<s1.size(); i++)
        {
            if(flag==1)
            {
                if(s1[i]=='1')
                {
                    sum[i+1]=sum[i]+i+time[i];
                    flag=2;
                }
                else if(s1[i]=='0')
                {
                    flag=1;
                    sum[i+1]=sum[i]+2*i+time[i];
                }
            }
            else
            {
                if(s2[i]=='1')
                {
                    sum[i+1]=sum[i]+i+time[i];
                    flag=1;
                }
                else if(s2[i]=='0')
                {
                    sum[i+1]=sum[i]+2*i+time[i];
                    flag=2;
                }
            }
            res+=sum[i+1];
        }
        cout<<res<<endl;
    }
    return 0;
}

詳細信息

Test #1:

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

input:

3
101
011
11010

output:

12
15
43

result:

ok 3 lines

Test #2:

score: -100
Wrong Answer
time: 148ms
memory: 4872kb

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
61249915
69
61249948
279
345
14
106
16506145382
791
621
60004644
764
61249996
16504839795
736
227971
6
15
542
44
16170601029
61249915
140
833
497
596
24
16504839700
694
462
30
425
14
1840
228066
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
1...

result:

wrong answer 4th lines differ - expected: '1515', found: '61249915'