Submission #476758

#TimeUsernameProblemLanguageResultExecution timeMemory
476758ponytailArranging Shoes (IOI19_shoes)C++17
10 / 100
1 ms204 KiB
#include <bits/stdc++.h> using namespace std; const int MAXN = 1e5 + 5; typedef long long ll; int n; int inv(int x){ if(x<0) return -x; else if(x>n) return x - n; else return x + n; } mt19937 rng((int)std::chrono::steady_clock::now().time_since_epoch().count()); ll count_swaps(vector<int> S) { int nxt = 0; int ans = 0; for(int i=0; i<S.size(); i++) { if(S[i] < 0) { for(int j=i-1; j>=nxt; j--) { swap(S[j], S[j+1]); ans++; } for(int j=nxt+1; j<S.size(); j++) { if(S[j] == -S[i]) { for(int k=j-1; k>=nxt+1; k--) { swap(S[k], S[k+1]); ans++; } break; } } } } return ans; } void solve() { int n; cin >> n; vector<int> v(2*n); for(int i=0; i<2*n; i++) cin >> v[i]; cout << count_swaps(v) << "\n"; }

Compilation message (stderr)

shoes.cpp: In function 'll count_swaps(std::vector<int>)':
shoes.cpp:15:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   15 |     for(int i=0; i<S.size(); i++) {
      |                  ~^~~~~~~~~
shoes.cpp:20:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   20 |             for(int j=nxt+1; j<S.size(); j++) {
      |                              ~^~~~~~~~~
#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...