답안 #1082741

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1082741 2024-09-01T11:27:05 Z nickolasarapidis Arranging Shoes (IOI19_shoes) C++17
10 / 100
1 ms 348 KB
#include "shoes.h"
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
 
ll count_swaps(vector<int> S){
	int N = S.size();
 
	ll ans = 0;
 
	map<int, ll> m;
	map<int, vector<int>> id;

	for(int i = 0; i < N; i++){
		if(m[-S[i]] > 0){
			if(S[i] < 0){
				m[-S[i]]--;
		 		ans += i - id[-S[i]].back();
		 		id[-S[i]].pop_back();
			}
			else{
				m[-S[i]]--;
		 		ans += i - id[-S[i]].back() - 1;
		 		id[-S[i]].pop_back();
			}
		}
		else{
			m[S[i]]++;
			id[S[i]].push_back(i);
		}
	}
 
	return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Incorrect 0 ms 348 KB Output isn't correct
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 0 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Incorrect 0 ms 348 KB Output isn't correct
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Incorrect 0 ms 348 KB Output isn't correct
8 Halted 0 ms 0 KB -