| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 | 
|---|---|---|---|---|---|---|---|
| 418903 | FlippenFaz | Arranging Shoes (IOI19_shoes) | C++14 | 1087 ms | 57700 KiB | 
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "shoes.h"
using namespace std;
typedef long long ll;
#define SIZE 131072
map<int, queue<int>> shoesList;
vector<ll> offset;
void incOff(int pos) {
	pos+=SIZE;
	while (pos > 0) {
		offset[pos]++;
		pos/=2;	
	}
}
ll getOff(int pos) {
	if(pos == -1) {
		return 0;
	}
	ll sum = 0;
	int left = SIZE;
	int right = pos + SIZE;
	while (left <= right) {
		if (left%2 == 1) {sum+=offset[left++];}
		if (right%2 == 0) {sum+=offset[right--];}
		left/=2;
		right/=2;
	}
	return sum;
}
ll count_swaps(vector<int> s) {
	ll sum = 0;
	offset.resize(262144);
	cerr << "OFFSET: " << offset[0] << " " << offset[100] << endl << endl;
	for (ll i = 0; i < s.size(); i++) {
		ll pos = 0;
		if (s[i] > 0) {pos = i;}
		else {pos = i+1;}
		cerr << endl;
		cerr << "I: " << i << " SHOE: " << s[i] << endl;
		cerr << "SIZE: " << shoesList[-s[i]].size() << "POS OF INVERSE:" << shoesList[-s[i]].front() << endl;
		cerr << "CUROFFSET 0: " << offset[SIZE] << "TOTAL: " << offset[1] << endl;
		if (shoesList[-s[i]].size() == 0) {
			shoesList[s[i]].push(pos);
		} else {
			int prev = -1;
			int curPos = shoesList[-s[i]].front();
			cerr << "GET OFF CUR: " << getOff(curPos) << "GET OFF PREV: " << getOff(prev) << endl;
			while ( (getOff(curPos) - getOff(prev)) > 0) {
				int temp = curPos;
				curPos = curPos + getOff(curPos) - getOff(prev);
				prev = temp;
			}
			cerr << endl;
			cerr << "ACTUAL INVPOS: " << curPos << endl;
			sum += (i - curPos);
			cerr << "INCREMENTING: " << curPos << endl;
			incOff(curPos);
			shoesList[-s[i]].pop(); 
		}
	}
	return sum;
}
컴파일 시 표준 에러 (stderr) 메시지
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
