제출 #211230

#제출 시각아이디문제언어결과실행 시간메모리
211230eric_xiaoArranging Shoes (IOI19_shoes)C++14
0 / 100
10 ms9728 KiB
#include<bits/stdc++.h> #define ll long long using namespace std; ll BIT[200009]; ll cnt[200009]; vector<ll> A[200009],B[200009]; ll N; void add(ll p,ll v) { while(p <= N) { BIT[p] += v; p += (p & (-p)); } } ll sum(ll p) { ll ret = 0; while(p > 0) { ret += BIT[p]; p -= (p & (-p)); } return ret; } ll count_swaps(vector<int> S) { ll ans,i; N = S.size(); for(i = 1;i <= N;i++) { add(i,1); if(S[i-1] > 0) { A[S[i-1]].push_back(i); } else { B[-S[i-1]].push_back(i); } } for(i = 1;i <= N;i++) { ll nw = cnt[abs(S[i-1])]; if((S[i-1] < 0 && B[abs(S[i-1])][nw] != i) || (S[i-1] > 0 && A[abs(S[i-1])][nw] != i)) { continue; } cnt[abs(S[i-1])]++; ll pr; if(S[i-1] < 0) { pr = A[abs(S[i-1])][nw]; } else { pr = B[abs(S[i-1])][nw]; ans++; } ans += sum(pr); add(i,-1); add(pr,-1); } return ans; }

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

shoes.cpp: In function 'long long int count_swaps(std::vector<int>)':
shoes.cpp:64:12: warning: 'ans' may be used uninitialized in this function [-Wmaybe-uninitialized]
     return ans;
            ^~~
#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...