제출 #413975

#제출 시각아이디문제언어결과실행 시간메모리
413975asfd221Arranging Shoes (IOI19_shoes)C++14
컴파일 에러
0 ms0 KiB
#define INF (ll)(2e9)
#define MD (998244353)
#define pb push_back
#define mp make_pair
#define ft first
#define sd second

using namespace std;
using ll = long long;
using cd = complex<double>;
using ul = unsigned long;

void f_io () { ios_base :: sync_with_stdio (false); cin.tie (nullptr);
 cout.tie (nullptr);
}

const ll MAX = 2e5 + 5, MOD = 998244353, M = 3e6;

ll gc (ll a, ll b) {
	if (!a || !b) {
		return max (a, b);
	}
	ll r = a % b;
	while (r) {
		a = b;
		b = r;
		r = a % b;
	}
	return b;
}

ll mult (ll a, ll b) {
	return ((a % MOD)  * 1LL * (b % MOD)) % MOD;
}

ll add (ll a, ll b) {
	b = (b % MOD + MOD) % MOD;
	return (a + b) % MOD;
}

ll pw (ll a, ll b) {
	if (b < 0) {
		return 1;
	}
	ll r = 1;
	while (b) {
		if (b & 1) {
			r = mult (a, r);
		}
		b >>= 1;
		a = mult (a, a);
	}
	return r;
}
int f[MAX];

void up (int x, int v) {
	x++;
	for (int i = x; i < MAX; i += i & (-i)) {
		f[i] += v;
	}
}

ll an (int x) {
	ll s = 0;
	x++;
	for (int i = x; i; i -= i & (-i)) {
		s += f[i];
	}
	return s;
}

ll inv (vector<int> v) {
	for (ll i = 0; i < (int)v.size () + 10; i++)  {
		f[i] = 0;
	}
	ll a =0;
	for (ll i = v.size () - 1; i >= 0; i--) {
		a += an (v[i]);
		up (v[i] + 1, 1);
	}
	return a;
}

ll count_swaps (vector<int> ve) {
	int n = ve.size ();
	vector<int> vv (n), v2 (n);
	int cc = 0, c[n + 1] = {}, c2 = 1, d[n + 1] = {};
	vector<int> id[n + 1], i2[n + 1];
	for (int i = 0; i < n; i++) {
		if (ve[i] < 0) {
			vv[i] = cc;
			id[-ve[i]].pb (cc);
			cc += 2;
		}
		else {
			v2[i] = c2;
			i2[ve[i]].pb (c2);
			c2 += 2;
		}
	}
	for (int i = 0; i < n; i++) {
		if (ve[i] > 0) {
			vv[i] = id[ve[i]][c[ve[i]]++] + 1;
		}
		else {
			vv[i] = i2[-ve[i]][d[-ve[i]]++] - 1;
		}
	}
	return min (inv (vv), inv (v2));
}
			

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

shoes.cpp:10:12: error: 'complex' does not name a type
   10 | using cd = complex<double>;
      |            ^~~~~~~
shoes.cpp: In function 'void f_io()':
shoes.cpp:13:16: error: 'ios_base' has not been declared
   13 | void f_io () { ios_base :: sync_with_stdio (false); cin.tie (nullptr);
      |                ^~~~~~~~
shoes.cpp:13:53: error: 'cin' was not declared in this scope
   13 | void f_io () { ios_base :: sync_with_stdio (false); cin.tie (nullptr);
      |                                                     ^~~
shoes.cpp:1:1: note: 'std::cin' is defined in header '<iostream>'; did you forget to '#include <iostream>'?
  +++ |+#include <iostream>
    1 | #define INF (ll)(2e9)
shoes.cpp:14:2: error: 'cout' was not declared in this scope
   14 |  cout.tie (nullptr);
      |  ^~~~
shoes.cpp:14:2: note: 'std::cout' is defined in header '<iostream>'; did you forget to '#include <iostream>'?
shoes.cpp: In function 'll gc(ll, ll)':
shoes.cpp:21:10: error: 'max' was not declared in this scope
   21 |   return max (a, b);
      |          ^~~
shoes.cpp: At global scope:
shoes.cpp:73:9: error: 'vector' was not declared in this scope
   73 | ll inv (vector<int> v) {
      |         ^~~~~~
shoes.cpp:1:1: note: 'std::vector' is defined in header '<vector>'; did you forget to '#include <vector>'?
  +++ |+#include <vector>
    1 | #define INF (ll)(2e9)
shoes.cpp:73:16: error: expected primary-expression before 'int'
   73 | ll inv (vector<int> v) {
      |                ^~~
shoes.cpp:85:17: error: 'vector' was not declared in this scope
   85 | ll count_swaps (vector<int> ve) {
      |                 ^~~~~~
shoes.cpp:85:17: note: 'std::vector' is defined in header '<vector>'; did you forget to '#include <vector>'?
shoes.cpp:85:24: error: expected primary-expression before 'int'
   85 | ll count_swaps (vector<int> ve) {
      |                        ^~~