QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#318995#4935. Exchange Bottleneckowen0806#WA 3ms4388kbC++201.2kb2024-02-01 14:14:342024-02-01 14:14:35

Judging History

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

  • [2024-02-01 14:14:35]
  • 评测
  • 测评结果:WA
  • 用时:3ms
  • 内存:4388kb
  • [2024-02-01 14:14:34]
  • 提交

answer

#include<bits/stdc++.h>
#define endl '\n'
#define int long long
#define pii pair<int, int>
using namespace std;
const int N = 2e5 + 100 , MXN = 1e6 + 100 , INF = 0x3f3f3f3f3f3f3f3f;
int arr[N];
void solve(){
    int n;cin >> n;
    int a_one = 1, a_zero = 1, cnt0 = 0;
    for(int i = 2;i <= n;i++){
        cin >> arr[i];
        if(arr[i] == 0)a_one = 0;
        if(arr[i] == 1)a_zero = 0;
        if(a_zero) cnt0++;
    }
    if(a_one){
        cout << 1 << endl;
        return;
    }
    if(a_zero){
        cout << n - 1 << endl;
        return;
    }
    for(int i = n;i >= 2;i--){
        if(arr[i] == 1){
            if(i == n)cout << 2 << endl;
            else if(cnt0) cout << n - i + 2 << endl;
            else cout << n - i + 1 << endl;
            break;
        }
    }
}
signed main(){
    ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    // freopen("C:\\Users\\charl\\Desktop\\C++\\_in.txt", "r", stdin);
    // freopen("C:\\Users\\charl\\Desktop\\C++\\_out.txt", "w", stdout);

    int T = 1;
    //cin >> T;
    for(int i = 1;i <= T;i++){
        // cout << "Case #" << i << ": ";
        solve();
    }

}

詳細信息

Test #1:

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

input:

5
1 0 1 0

output:

2

result:

ok single line: '2'

Test #2:

score: 0
Accepted
time: 0ms
memory: 3592kb

input:

7
1 1 1 1 1 1

output:

1

result:

ok single line: '1'

Test #3:

score: 0
Accepted
time: 0ms
memory: 3544kb

input:

2
0

output:

1

result:

ok single line: '1'

Test #4:

score: 0
Accepted
time: 3ms
memory: 4388kb

input:

90580
1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 0 1 1 1 1 0 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 0 0 1 1 1 1 1 1 0 1 1 1 1 1 0 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 0 0 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 0 1 1 1 1 1 1 1 1 1 1 ...

output:

2

result:

ok single line: '2'

Test #5:

score: 0
Accepted
time: 3ms
memory: 4200kb

input:

83502
0 1 1 1 0 0 0 0 1 1 0 1 0 1 0 1 1 1 1 0 1 1 1 1 0 1 0 1 1 1 0 1 0 0 0 1 1 1 1 1 1 0 1 0 1 0 1 1 1 1 0 1 1 0 0 0 0 1 1 0 0 1 0 1 0 0 1 1 1 1 1 1 1 0 0 0 1 1 0 1 0 0 1 0 1 1 0 0 0 1 1 1 1 0 1 0 1 1 1 1 1 1 1 0 0 0 1 0 0 0 0 0 1 1 0 1 0 0 1 0 0 1 1 1 1 0 0 1 0 1 1 0 1 0 1 0 0 0 0 1 0 1 0 1 0 0 0 ...

output:

2

result:

ok single line: '2'

Test #6:

score: -100
Wrong Answer
time: 1ms
memory: 3764kb

input:

12702
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 ...

output:

19

result:

wrong answer 1st lines differ - expected: '18', found: '19'