Submission #198645

#TimeUsernameProblemLanguageResultExecution timeMemory
198645DEDAArranging Shoes (IOI19_shoes)C++14
Compilation error
0 ms0 KiB
/* _____ ____ _____ ___ ___ ___ ___ |_ _/ __ \_ _| |__ \ / _ \ |__ \ / _ \ | || | | || | ) | | | | ) | | | | | || | | || | / /| | | | / /| | | | _| || |__| || |_ / /_| |_| | / /_| |_| | |_____\____/_____| |____|\___/ |____|\___/ */ #include <bits/stdc++.h> #include "shoes.h" #define rep(i, a, b) for (int i = (a); i < (b); i++) #define per(i, a, b) for (int i = (a); i > (b); i--) #define a(x) (x.begin(), x.end()) #define ar(x) (x.rbegin(), x.rend()) #define pb push_back #define Pb() pop_back() #define ll long long int #define ull unsigned long long int #define pii pair<int, int> #define pll pair<ll, ll> #define sc scanf #define scin(x) sc("%d", &(x)) #define scln(x) sc("%lld", &(x)) #define pf prllf #define ms(a, b) memset(a, b, sizeof(a)) #define mp make_pair #define db double #define EPS 10E-10 #define ff first #define ss second #define sqr(x) (x) * (x) #define vi vector<int> #define vl vector<ll> #define vii vector<vector<int>> #define vll vector<vector<ll>> #define DBG pf("HI\n") #define MOD 1000000007 #define CIN \ ios_base::sync_with_stdio(0); \ cin.tie(0); \ cout.tie(0) #define RUN_CASE(t, T) for (__typeof(t) t = 1; t <= T; t++) #define CASE(t) prllf("Case %d: ", t) #define CASEL(t) prllf("Case %d:\n", t) #define intlimit 2147483647 #define longlimit 9223372036854775807 #define infinity (1 << 28) #define gcd(a, b) __gcd(a, b) #define lcm(a, b) ((a) * (b) / gcd(a, b)) #define PI 2 * acos(0.0) // assert(x==y); gives run time when false using namespace std; long long count_swaps(vector<int> &v) { ll n = v.size(), sum = 0; per(i, n - 1, 0) { if (i==n-1 || abs(v[i]) != v[i + 1]) { ll j = i - 1; if (v[i] > 0) { while (abs(v[j]) != v[i]) { j--; } per(k, i, j) { swap(v[k], v[k - 1]); sum++; } } else { while (v[j] != abs(v[i])) { j--; } per(k, i, j - 1) { swap(v[k], v[k - 1]); sum++; } } } } return sum; }

Compilation message (stderr)

/tmp/ccj8Z3JS.o: In function `main':
grader.cpp:(.text.startup+0x272): undefined reference to `count_swaps(std::vector<int, std::allocator<int> >)'
collect2: error: ld returned 1 exit status