QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#213057#4803. Candiesucup-team1209#WA 0ms3644kbC++201.2kb2023-10-14 10:36:582023-10-14 10:36:59

Judging History

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

  • [2023-10-14 10:36:59]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3644kb
  • [2023-10-14 10:36:58]
  • 提交

answer

#include <bits/stdc++.h>
#define cs const
#define pb push_back
using namespace std;

cs int N = 1e5 + 5; 
int n, X, a[N], pre[N], suf[N];
queue <int> q; 
bool era[N];
void del(int x) {
    era[x] = 1; 
    pre[suf[x]] = pre[x];
    suf[pre[x]] = suf[x];
}
int main() {
    #ifdef zqj 
    freopen("1.in","r",stdin);
    #endif
    ios::sync_with_stdio(false),cin.tie(0);
    cin >> n >> X;
    vector <int> s; 
    
    for(int i = 0; i < n; i++) {
        cin >> a[i];
    } a[n] = a[0];
    for(int i = 0; i < n; i++) {
        pre[i] = i - 1, suf[i] = i + 1; 
    }
    pre[0] = n - 1; 
    suf[n - 1] = 0;
    for(int i = 0; i < n; i++) {
        if(a[i] + a[i + 1] == X || a[i] == a[i + 1]) {
            q.push(i);
        }
    }
    int cnt = 0; 
    while(!q.empty()) {
        int x = q.front(); q.pop();
        if(era[x]) continue;
        ++ cnt; 
        // cout << x <<' ' << suf[x] << endl;
        if(cnt == n / 2) break;
        int y = suf[x];
        if(a[x] == a[y] || a[x] + a[y] == X) {
            del(x), del(y);
        }
        x = pre[x];
        if(a[x] == a[suf[x]] || a[x] + a[suf[x]] == X) q.push(x);
    } 
    cout << cnt << '\n';
    return 0; 
}

詳細信息

Test #1:

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

input:

6 5
1 1 4 5 1 4

output:

2

result:

ok 1 number(s): "2"

Test #2:

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

input:

10 5
1 2 5 2 1 2 3 4 8 4

output:

3

result:

ok 1 number(s): "3"

Test #3:

score: -100
Wrong Answer
time: 0ms
memory: 3612kb

input:

1 963837006
731841442

output:

1

result:

wrong answer 1st numbers differ - expected: '0', found: '1'