제출 #1233658

#제출 시각아이디문제언어결과실행 시간메모리
1233658retr0foxxArranging Shoes (IOI19_shoes)C++20
10 / 100
6 ms9800 KiB
#include "shoes.h" #include <iostream> /* a certain segment... */ using haha = int; #define int long long #define printf // #define MAXN 20 #define MAXN 200005 int fenwick[MAXN]; int fwlen; void fwadd(int i, int x) { ++i; if (i < 1) i = 1; if (i > fwlen) return; while (i <= fwlen) { fenwick[i] += x; i += i & (-i); } } int fwget(int i) { ++i; if (i < 1) return 0; if (i > fwlen) i = fwlen; int result = 0; while (i >= 1) { result += fenwick[i]; i -= i & (-i); } return result; } std::vector<int> stack_neg[MAXN]; std::vector<int> stack_pos[MAXN]; long long count_swaps(std::vector<haha> s) { printf("where is it breaking?\n"); fwlen = s.size(); int result = 0; for (int i = 0; i < s.size(); ++i) { printf("wat da hell\n"); int current = s[i]; int left = current < 0; current = std::abs(current); printf("Tree state is: "); for (int i = 0; i < s.size(); ++i) printf("%i ", fwget(i)); printf("\n"); if (left && stack_pos[current].size()) { printf("negative %i in index %i got a pair in %i (%i)\n", current, i, stack_pos[current].back(), stack_pos[current].back() + fwget(stack_pos[current].back())); result += i - (stack_pos[current].back() + fwget(stack_pos[current].back())); fwadd(stack_pos[current].back(), 1); fwadd(i, -1); stack_pos[current].pop_back(); } else if (left) stack_neg[current].push_back(i); if (!left && stack_neg[current].size()) { printf("positive %i in index %i got a pair in %i (%i)\n", current, i, stack_neg[current].back(), stack_neg[current].back() + fwget(stack_neg[current].back())); result += i - (stack_neg[current].back() + fwget(stack_neg[current].back())) - 1; fwadd(stack_neg[current].back() + 1, 1); fwadd(i, -1); stack_neg[current].pop_back(); } else if (!left) stack_pos[current].push_back(i); } // std::cout << result << std::endl; return result; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...