# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1091203 | kukuk | Arranging Shoes (IOI19_shoes) | C++14 | 52 ms | 21956 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "shoes.h"
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef unsigned long long int ull;
const ll md = 1e9+7;
const int ukr = 2e5+10;
int read() {
int ketek = 0; bool ne=0;
register char c = getchar();
while(c == ' ' or c =='\n') c =getchar();
if(c=='-'){ne = 1; c = getchar();}
while(c >= '0' and c <='9') { ketek = (ketek<<3)+(ketek<<1)+c-'0'; c = getchar();}
if(ne) ketek*=-1;
return ketek;
}
void print(int x) {
if (x < 0) {putchar('-');x = -x;}
int len = 0, buf[10];
if (x == 0) {putchar('0');return;}
while (x > 0) {buf[len++] = x % 10; x/=10;}
while (len > 0) {putchar('0' + buf[--len]);}
}
void File_Work(){
freopen("test.in","r",stdin);
freopen("test.out","w",stdout);
}
int n, m, a, b, c, d, id;
struct babi{
ll x, y, id;
};
struct babis{
ll x, y;
};
ll gcd(ll a, ll b) {
if (b == 0) return a;
return gcd(b, a % b);
}
ll pgkt(ll rnx, ll rny){
if(rny == 0) return 1;
ll nwrn = pgkt(rnx, rny/2);
if(rny%2){
return (((nwrn*nwrn)%md)*rnx)%md;
}else{
return (nwrn*nwrn)%md;
}
}
vector<int> v;
string s;
ll fen[ukr];
vector<ll> ki[ukr];
vector<ll> ka[ukr];
vector<pair<ll,ll>> pas;
void upd(ll rn){
for(; rn < ukr; rn += (rn&-rn)){
fen[rn]++;
}
}
ll get(ll rn){
ll tot = 0;
for(; rn > 0; rn -= (rn&-rn)){
tot += fen[rn];
}
return tot;
}
ll count_swaps(vector<int> s) {
n = s.size();
for(int i = 0; i < n; i++){
if(s[i] < 0){
ki[-s[i]].push_back(i);
}else{
ka[s[i]].push_back(i);
}
}
ll ans = 0;
for(int i = 0; i < n; i++){
while(!ki[i].empty()){
if(ki[i].back() > ka[i].back()){
ans++;
swap(ki[i].back(), ka[i].back());
}
pas.push_back({ki[i].back(), ka[i].back()});
ki[i].pop_back(); ka[i].pop_back();
}
}
sort(all(pas));
for(auto [l, r] : pas){
ans += r-l-1-(get(r)-get(l));
upd(r);
}
return ans;
}
/* void solve(){
cin >> n;
vector<int> sem;
for(int i = 0; i < 2*n; i++){
cin >> id;
sem.push_back(id);
}
cout << count_swaps(sem) << "\n";
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
int t =1;
//cin >> t;
for(int i = 1; i <= t; i++){
//cout << "Case " << i << ": ";
solve();
}
} */
컴파일 시 표준 에러 (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... |