QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#446730#6386. Dollsnikaa1230 5ms16988kbC++172.2kb2024-06-17 15:30:012024-06-17 15:30:03

Judging History

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

  • [2024-06-17 15:30:03]
  • 评测
  • 测评结果:0
  • 用时:5ms
  • 内存:16988kb
  • [2024-06-17 15:30:01]
  • 提交

answer

// #pragma GCC diagnostic warning "-std=c++11"
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize ("O3")
// #pragma GCC optimization ("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma")
#include <bits/stdc++.h>
using namespace std;
 
// #define int long long
#define eb emplace_back
#define mp make_pair
#define pb push_back
#define pp pop_back
#define endl '\n'
#define ff first
#define ss second
#define stop exit(0)
#define sz(x) (int)x.size()
#define pause system("pause")
#define all(x) (x).begin(),(x).end()
#define deb(x) cout << #x << "-" << x  << endl
 
typedef char chr;
typedef string str;
typedef long long ll;
typedef vector <int> vii;
typedef pair <int,int> pii;
 
const long long INF = LLONG_MAX;
const int inf = INT_MAX;
const int mod = 998244353;
const int MOD = 1e9 + 7;
const int dx[] = {0,0,-1,1};
const int dy[] = {-1,1,0,0};
const double PI = 2 * acos(0.0);

const int N = 5e5 + 5;

int n,a[N],fix[N],parent[N];
vector <vii> lst(N);
int ans;

void makeset(int x) {
    lst[x] = vector<int>(1,x);
    parent[x] = x;
}

int getparent(int x) {
    return parent[x];
}

void unionset(int a, int b) {
    a = parent[a];
    b = parent[b];
    if (a == b) return;
    if (sz(lst[a]) < sz(lst[b])) swap(a,b);
    while (sz(lst[b])) {
        int c = lst[b].back();
        parent[c] = a;
        lst[a].pb(c);
        lst[b].pp();
    }
}

inline void test_case () {  
    
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        makeset(a[i]);
    }
    for (int i = 1; i <= n; i++) {
        int ans1 = (sz(lst[getparent(a[i]-1)])+1)/2 * fix[a[i]-1] + (sz(lst[getparent(a[i]+1)])+1)/2 * fix[a[i]+1];
        if (fix[a[i]-1]) unionset(a[i],a[i]-1);
        if (fix[a[i]+1]) unionset(a[i],a[i]+1);
        int ans2 = (sz(lst[getparent(a[i])])+1)/2;
        ans += max(0,ans2-ans1);
        cout << ans << " ";
        fix[a[i]] = 1;
    }
    

}
 
signed main () {
 
    ios_base :: sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    
    int T = 1;
    // cin >> T;
    while(T--) {
        test_case();
    }
    
    return 0;
 
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 23
Accepted
time: 0ms
memory: 16804kb

input:

190
57 94 24 27 110 44 72 82 55 7 9 43 22 86 95 84 125 16 75 28 46 10 14 131 112 132 33 53 103 139 118 126 137 13 140 77 25 23 47 116 68 150 81 97 165 58 88 63 42 89 123 11 113 83 124 130 80 35 143 155 153 48 8 136 104 101 90 37 21 99 142 34 64 115 109 26 92 144 61 51 114 49 148 96 60 30 54 134 141 ...

output:

1 2 3 4 5 6 7 8 9 10 11 11 12 13 13 14 15 16 17 17 18 18 19 20 21 21 22 23 24 25 26 26 27 27 27 28 28 28 28 29 30 31 31 32 33 33 34 35 36 36 37 38 38 38 38 39 40 41 42 43 44 45 45 45 45 46 47 48 49 50 50 50 50 50 50 50 51 52 53 54 55 55 56 56 56 57 57 58 58 58 58 59 59 60 60 60 61 61 62 63 63 63 63 ...

result:

ok single line: '1 2 3 4 5 6 7 8 9 10 11 11 12 ... 77 77 77 77 77 77 77 77 77 77 '

Test #2:

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

input:

158
46 39 57 35 42 43 60 87 44 38 89 92 41 70 78 58 48 59 51 37 36 49 77 76 71 47 50 88 45 40 36 39 92 36 39 45 46 58 51 49 47 37 47 43 87 77 45 39 89 59 57 42 89 76 76 37 47 77 36 77 60 89 40 36 45 40 76 92 88 37 46 88 46 46 36 59 78 92 35 89 60 89 77 45 70 45 70 78 51 51 92 42 35 76 60 51 35 59 49...

output:

1 2 3 4 5 5 6 7 8 8 9 10 10 11 12 12 13 13 14 15 15 15 15 16 16 16 16 16 17 17 17 17 18 18 18 18 18 18 18 18 18 18 18 18 18 18 18 18 18 18 18 18 18 18 18 18 18 18 18 18 18 18 18 18 18 18 18 19 19 19 19 19 19 19 19 19 19 20 20 20 20 20 20 20 20 20 20 20 20 20 21 21 21 21 21 21 21 21 21 21 21 21 21 21...

result:

wrong answer 1st lines differ - expected: '1 2 3 4 5 5 6 7 8 8 9 10 10 11...7 17 17 17 17 17 17 17 17 17 17', found: '1 2 3 4 5 5 6 7 8 8 9 10 10 11... 21 21 21 21 21 21 21 21 21 21 '

Subtask #2:

score: 0
Wrong Answer

Test #22:

score: 0
Wrong Answer
time: 5ms
memory: 16764kb

input:

3922
1195 63679 1195 96797 63679 60311 456263 228361 96797 270167 60311 169529 60311 60311 456263 270167 169529 375829 169529 169529 270167 375829 60311 228361 1195 375829 96797 375829 375829 96797 375829 169529 456263 375829 1195 375829 456263 96797 169529 228361 63679 270167 212365 456263 270167 9...

output:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 ...

result:

wrong answer 1st lines differ - expected: '1 2 2 3 3 4 5 6 6 7 7 8 8 8 8 ...0 10 10 10 10 10 10 10 10 10 10', found: '1 2 3 4 5 6 7 8 9 10 11 12 13 ... 3917 3918 3919 3920 3921 3922 '

Subtask #3:

score: 0
Skipped

Dependency #2:

0%

Subtask #4:

score: 0
Skipped

Dependency #1:

0%