제출 #249205

#제출 시각아이디문제언어결과실행 시간메모리
249205Dilshod_ImomovArranging Shoes (IOI19_shoes)C++17
15 / 100
34 ms3200 KiB
# include <bits/stdc++.h> # define ll long long # define speed ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0) using namespace std; const int MAX_N = 100007; ll count_swaps( vector < int > s ) { speed; ll n = s.size(), sz = 0; /* ll ans = 0; vector < int > ids, used(n), vc[2 * MAX_N]; for ( int i = 0; i < n; i++ ) { s[i] += MAX_N; vc[s[i]].push_back( i ); } // cout << "Done 1" << endl; for ( int i = 0; i < n; i++ ) { if ( used[i] ) { continue; } s[i] -= MAX_N; int l = i, r = *vc[-s[i] + MAX_N].begin(); // cout << "Done 2 " << l << ' ' << r << endl; vc[ s[i] + MAX_N ].erase( vc[ s[i] + MAX_N ].begin() ); int rr = r; used[r] = 1; vc[-s[i] + MAX_N].erase( vc[-s[i] + MAX_N].begin() ); int x = upper_bound( ids.begin(), ids.end(), i ) - ids.begin(); x = sz - x; l += x; x = upper_bound( ids.begin(), ids.end(), r ) - ids.begin(); x = sz - x; r += x; ans += r - l - 1; if ( s[i] > 0 ) { ans++; } sz++; ids.push_back( rr ); }*/ n /= 2; n--; return n * (n + 1) / 2; // return ans; } /* int main() { ll n; cin >> n; vector < int > S(2 * n); for ( ll i = 0; i < 2 * n; i++ ) { cin >> S[i]; } cout << count_swaps( S ); } */

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

shoes.cpp: In function 'long long int count_swaps(std::vector<int>)':
shoes.cpp:10:19: warning: unused variable 'sz' [-Wunused-variable]
  ll n = s.size(), sz = 0;
                   ^~
#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...