QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#826132#9790. Make Swamp Great Againcharlyjoe#TL 0ms3592kbC++201.3kb2024-12-22 02:58:402024-12-22 02:58:46

Judging History

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

  • [2024-12-22 02:58:46]
  • 评测
  • 测评结果:TL
  • 用时:0ms
  • 内存:3592kb
  • [2024-12-22 02:58:40]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
using ii = pair<int,int>;
using vii = vector<ii>;
using vi = vector<ll>;
ll gcd(ll a, ll b) {return a == 0? b: gcd(b%a,a);}
ll lcm(ll a, ll b) {return a * (b / gcd(a,b));}
#define pb push_back
#define FOR(i,a,b)  for(int i = (a); i < (b); i++)
#define all(x) (x).begin(), (x).end()
#define endl '\n'
#define lb(v,a) lower_bound(v.begin(),v.end(),a)-v.begin()
#define ub(v,a) upper_bound(v.begin(),v.end(),a)-v.begin()-1
    
    bool check(vi& num, ll x){
        ll n = num.size();
        FOR(i,0,n){
            ll idxf = (i + 1) % n, idxs = (i + 2) % n;
            ll fir = num[i], sec = num[idxf], ter = num[idxs];
            if (x == min({fir, sec, ter}) || x == max({fir, sec, ter})) {
                return true;
            }
        }
    return false;
    }


    int main(){
        ios::sync_with_stdio(0);
        cin.tie(0);
        ll n; cin >> n;
        vi num(n);
        map<ll,ll> mp;
        FOR(i,0,n) {cin >> num[i]; mp[num[i]]++;}
        vi ans(n);
        FOR(i,0,n){
            if(check(num,num[i])) ans[i] = n-mp[num[i]];
            else ans[i] = n-mp[num[i]]+1;
        }
        for(auto x : ans) cout << x << " "; cout << endl;
    }

详细

Test #1:

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

input:

6
4 7 47 4 77 47

output:

4 6 4 4 5 4 

result:

ok single line: '4 6 4 4 5 4 '

Test #2:

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

input:

6
4 7 47 4 77 47

output:

4 6 4 4 5 4 

result:

ok single line: '4 6 4 4 5 4 '

Test #3:

score: -100
Time Limit Exceeded

input:

34282
90425 22450 88504 38625 50256 24285 29693 59937 55013 65148 74544 79337 84799 18379 96719 45091 46959 34827 91934 5519 57325 75622 98980 11649 42236 14474 44579 97335 71798 95780 52228 34730 42473 53258 62204 12246 15037 67194 47 41533 22010 29201 65866 68828 26827 16763 76098 73625 5875 92559...

output:


result: