QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#774763#9790. Make Swamp Great Againucup-team4893#WA 8ms10308kbC++171.1kb2024-11-23 13:49:072024-11-23 13:49:07

Judging History

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

  • [2024-11-23 13:49:07]
  • 评测
  • 测评结果:WA
  • 用时:8ms
  • 内存:10308kb
  • [2024-11-23 13:49:07]
  • 提交

answer

#include<iostream>
#include<cstdio>
#include<map> 
#include<vector>
#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], cnt;

vector<int> g[100005];

inline int chk(int i) {
	return v[i] && (v[lst[i]] == -v[i] && v[nxt[i]] == -v[i]);
}

void modify(int i, int x) {
	cnt -= chk(lst[i]) + chk(i) + chk(nxt[i]);
	v[i] = x;
	cnt += chk(lst[i]) + chk(i) + chk(nxt[i]);
}

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]) modify(x, 0);
		for(int x : g[i - 1]) modify(x, -1);
		if(g[i].size()) {
			ans[i] = n - g[i].size() + cnt;
		}
	}
	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();
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 2ms
memory: 8004kb

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: 8748kb

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: 8ms
memory: 10308kb

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:

37315 40149 37789 42493 42960 40495 41385 42678 42864 42232 40865 39946 38716 39306 35387 42868 42920 42083 36892 36018 42798 40657 34616 37696 42704 38409 42861 35201 41336 35685 42933 42088 42743 42903 42545 37861 38519 42035 34308 42705 40083 41300 42161 41782 40986 38961 40539 41032 36107 36712 ...

result:

wrong answer 1st lines differ - expected: '34281 34281 34281 34281 34281 ...0 34280 34281 34281 34281 34281', found: '37315 40149 37789 42493 42960 ... 42093 40571 41192 42084 39667 '