제출 #532993

#제출 시각아이디문제언어결과실행 시간메모리
532993gun_ganArranging Shoes (IOI19_shoes)C++17
10 / 100
1061 ms16508 KiB
#include <bits/stdc++.h> using namespace std; template <typename T> struct Fenwick { vector<T> t; T n; Fenwick(T n) : n(n) { t.resize(n); } T g(T r){ T ret = 0; for (; r >= 0; r = (r & (r + 1)) - 1) ret += t[r]; return ret; } T sum(T l, T r){ return g(r) - g(l - 1); } void add(T i, T v){ for(;i < n; i = i | (i + 1)) t[i] += v; } void range_add(T l, T r, T v){ add(l, v); add(r + 1, -v); } }; long long count_swaps(vector<int> s){ long long n = s.size(), ans = 0; const int N = 1e5; vector<int> p[2 * N + 100]; for(int i=0;i<n;i++) { p[s[i] + N].push_back(i); } Fenwick<long long> fw(n + 100); vector<bool> vis(n); for(int i=0;i<n;i++) { if(vis[i]) continue; int pos = *lower_bound(p[-s[i] + N].begin(), p[-s[i] + N].end(), i + 1); for(auto i : vis) cerr << i << " "; cerr << '\n'; ans += (pos + fw.g(pos)) - (i + 1 + fw.g(i + 1)); vis[pos + fw.g(pos)] = 1; vis[i] = 1; fw.range_add(i+1, pos, 1); if(s[i] > s[pos]) { ans += 1; } } return ans; } // signed main(){ // int n; // cin >> n; // vector<int> t(2*n); // for(int i=0;i<2*n;i++) cin >> t[i]; // cout << count_swaps(t) << '\n'; // }

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

shoes.cpp: In function 'long long int count_swaps(std::vector<int>)':
shoes.cpp:45:3: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   45 |   for(auto i : vis) cerr << i << " "; cerr << '\n';
      |   ^~~
shoes.cpp:45:39: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   45 |   for(auto i : vis) cerr << i << " "; cerr << '\n';
      |                                       ^~~~
#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...