QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#780934#9790. Make Swamp Great AgainACloveWA 0ms6712kbC++141.1kb2024-11-25 14:05:212024-11-25 14:05:21

Judging History

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

  • [2024-11-25 14:05:21]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:6712kb
  • [2024-11-25 14:05:21]
  • 提交

answer

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

const int N = 1e5 + 114;
int n;
int a[N];
vector <int> v[N];
int ans[N];

int to(int x) { return a[(x - 1) % n + 1]; }

signed main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> n;
    for(int i = 1; i <= n; i = i + 1)
    {
        cin >> a[i];
        v[a[i]].push_back(i);
    }
    for(int i = 1; i <= n; i = i + 1)
    {
        int res = n - v[a[i]].size();
        bool flag = 1;
        for(auto j : v[a[i]])
        {
            if(flag == 0)
                break;
            if(max(max(to(j), to(j + 1)), to(j + 2)) == to(j) || min(min(to(j), to(j + 1)), to(j + 2)) == to(j))
                flag = 0;
            if(max(max(to(j - 1), to(j)), to(j + 1)) == to(j) || min(min(to(j - 1), to(j)), to(j + 1)) == to(j))
                flag = 0;
            if(max(max(to(j - 2), to(j - 1)), to(j)) == to(j) || min(min(to(j - 2), to(j - 1)), to(j)) == to(j))
                flag = 0;
        }
        cout << res + flag << " ";
    }
    cout << "\n";
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 6712kb

input:

6
4 7 47 4 77 47

output:

4 5 4 4 5 4 

result:

wrong answer 1st lines differ - expected: '4 6 4 4 5 4', found: '4 5 4 4 5 4 '