QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#446725 | #6389. Topical | nikaa123 | 0 | 15ms | 7456kb | C++23 | 2.2kb | 2024-06-17 15:28:17 | 2024-06-17 15:28:19 |
Judging History
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 = 2e5 + 5;
int n,a[N];
map <int,int> parent,fix;
map <int,vii> lst;
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: 0
Wrong Answer
time: 0ms
memory: 3520kb
input:
1 1 693647287 340782526
output:
1
result:
wrong answer 1st numbers differ - expected: '0', found: '1'
Subtask #2:
score: 0
Wrong Answer
Test #8:
score: 0
Wrong Answer
time: 1ms
memory: 3656kb
input:
100 1 893339036 896783899 690308537 201770764 262364362 105000893 770698921 744238454 470980016 935046317 642998516 100481910 392307650 116783134 196939768 372329082 346372520 43063564 245523488 389084350 130314590 412588681 987795927 681635353 304582580 472268968 700147283 743357606 792644412 99955...
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 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
result:
wrong answer 1st numbers differ - expected: '85', found: '1'
Subtask #3:
score: 0
Wrong Answer
Test #15:
score: 0
Wrong Answer
time: 15ms
memory: 7456kb
input:
10000 1 568857328 651788426 751475430 102940442 763289419 468657944 770847628 780257867 16919385 575963868 281824241 291248174 140016533 313529232 302186452 32709864 787073783 1926820 239509174 220454071 34252400 390385721 675239026 245106357 489697460 28435096 825528061 159083009 16370561 223299279...
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 numbers differ - expected: '10000', found: '1'
Subtask #4:
score: 0
Skipped
Dependency #1:
0%