제출 #143374

#제출 시각아이디문제언어결과실행 시간메모리
143374ondrahArranging Shoes (IOI19_shoes)C++14
컴파일 에러
0 ms0 KiB
#include "shoes.h"
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <set>
#include <map>

using namespace std;
using namespace __gnu_pbds;
typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;

long long count_swaps(std::vector<int> s) {
	long long ans = 0;
	int n = s.size();
	ordered_set<int> els;
	map<int, multiset<int>> M;
	for(int i = 0; i < n; i++) {
		els.insert(i);
		M[s[i]].insert(i);
	}
	for(int i = 0; i < n; i++) {
		if(s[i] == n+2)
			continue;
		int j = *M[-s[i]].begin();
		M[-s[i]].erase(M[-s[i]].begin());
		int pos1 = els.order_of_key(i);
		int pos2 = els.order_of_key(j);
		els.erase(els.find(j));
		ans += pos2-pos1;
		if(s[i] > 0) ans++;
		break;
	}
	return ans;
}

컴파일 시 표준 에러 (stderr) 메시지

shoes.cpp:8:9: error: 'tree' does not name a type; did you mean 'free'?
 typedef tree<
         ^~~~
         free
shoes.cpp: In function 'long long int count_swaps(std::vector<int>)':
shoes.cpp:19:2: error: 'ordered_set' was not declared in this scope
  ordered_set<int> els;
  ^~~~~~~~~~~
shoes.cpp:19:14: error: expected primary-expression before 'int'
  ordered_set<int> els;
              ^~~
shoes.cpp:22:3: error: 'els' was not declared in this scope
   els.insert(i);
   ^~~
shoes.cpp:30:14: error: 'els' was not declared in this scope
   int pos1 = els.order_of_key(i);
              ^~~