QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#774902 | #9790. Make Swamp Great Again | ucup-team4893# | WA | 12ms | 12564kb | C++17 | 2.1kb | 2024-11-23 14:10:17 | 2024-11-23 14:10:17 |
Judging History
answer
#include<iostream>
#include<cstdio>
#include<map>
#include<vector>
#include<cstring>
#define fopen(x, y) freopen(x".in", "r", stdin); freopen(y".out", "w", stdout);
#define int long long
#ifdef int
#define inf 0x3f3f3f3f3f3f3f3fll
#else
#define inf 0x3f3f3f3f
#endif
using namespace std;
int n, a[100005], ans[100005], v[100005], lst[100005], nxt[100005], c[100005], cnt;
vector<int> g[100005];
inline int lowbit(int x) { return x & (-x); }
struct BIT {
int c[100005];
BIT() {
memset(c, 0, sizeof(c));
}
void modify(int x, int v) {
for(int i = x; i <= n; i += lowbit(i)) {
c[i] += v;
}
}
int query(int x) {
int sum = 0; for(int i = x; i; i ^= lowbit(i)) sum += c[i]; return sum;
}
int query(int l, int r) {
if(l <= r) return query(r) - query(l - 1);
else return query(n) - query(l - 1) + query(r);
}
} f, ff;
void chk(int x, int d) {
if(v[x] == 1 && v[lst[x]] < 1 && v[nxt[x]] < 1) {
cout << x << "!" << d << "\n";
f.modify(x, d);
}
if(v[x] == -1 && v[lst[x]] > -1 && v[nxt[x]] > -1) {
cout << x << "," << d << "\n";
ff.modify(x, d);
}
}
void modify(int x, int c) {
chk(lst[x], -1); chk(x, -1); chk(nxt[x], -1);
v[x] = c;
chk(lst[x], 1); chk(x, 1); chk(nxt[x], 1);
}
void work() {
cin >> n;
for(int i = 1; i <= n; i++) {
cin >> a[i];
lst[i] = i % n + 1;
nxt[lst[i]] = i;
v[i] = 1;
g[a[i]].push_back(i);
}
for(int i = 1; i <= 100000; i++) {
for(int x : g[i]) v[x] = 0;
for(int x : g[i - 1]) v[x] = -1;
if(g[i].size()) {
ans[i] = n - g[i].size();
int flg = 1;
for(int x : g[i]) {
if(v[nxt[x]] >= v[x] && v[nxt[nxt[x]]] >= v[x] || v[nxt[x]] <= v[x] && v[nxt[nxt[x]]] <= v[x]) {
flg = 0;
break;
}
if(v[lst[x]] >= v[x] && v[lst[lst[x]]] >= v[x] || v[lst[x]] <= v[x] && v[lst[lst[x]]] <= v[x]) {
flg = 0;
break;
}
}
if(flg) ans[i]++;
}
}
for(int i = 1; i <= n; i++) {
cout << ans[a[i]] << ' ';
}cout << '\n';
}
signed main() {
// ios::sync_with_stdio(false); cin.tie(0);
int _ = 1;
// cin >> _;
while(_--) work();
}
詳細信息
Test #1:
score: 100
Accepted
time: 2ms
memory: 10852kb
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: 11476kb
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
Wrong Answer
time: 12ms
memory: 12564kb
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:
34281 34281 34281 34282 34281 34280 34281 34281 34281 34281 34281 34281 34281 34280 34281 34282 34282 34281 34281 34281 34281 34281 34280 34281 34282 34281 34281 34280 34282 34279 34281 34281 34281 34281 34281 34281 34282 34281 34281 34281 34281 34281 34280 34281 34281 34280 34281 34280 34281 34279 ...
result:
wrong answer 1st lines differ - expected: '34281 34281 34281 34281 34281 ...0 34280 34281 34281 34281 34281', found: '34281 34281 34281 34282 34281 ... 34280 34281 34281 34282 34281 '