QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#446714 | #6389. Topical | nikaa123 | 0 | 0ms | 7620kb | C++17 | 2.2kb | 2024-06-17 15:25:50 | 2024-06-17 15:25:51 |
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],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;
}
详细
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 7620kb
input:
1 1 693647287 340782526
output:
1
result:
wrong answer 1st numbers differ - expected: '0', found: '1'
Subtask #2:
score: 0
Runtime Error
Test #8:
score: 0
Runtime Error
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:
result:
Subtask #3:
score: 0
Runtime Error
Test #15:
score: 0
Runtime Error
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:
result:
Subtask #4:
score: 0
Skipped
Dependency #1:
0%