Submission #295021

#TimeUsernameProblemLanguageResultExecution timeMemory
295021SamAndArranging Shoes (IOI19_shoes)C++17
10 / 100
1095 ms2816 KiB
#include "shoes.h" #include <bits/stdc++.h> using namespace std; #define m_p make_pair #define fi first #define se second #define all(x) (x).begin(),(x).end() #define sz(x) ((int)(x).size()) typedef long long ll; const int N = 200005; int n; int a[N]; long long count_swaps(std::vector<int> s) { n = sz(s) / 2; for (int i = 1; i <= n * 2; ++i) a[i] = s[i - 1]; ll ans = 0; for (int i = 1; i <= n; ++i) { for (int j = (i - 1) * 2 + 1; j <= n * 2; ++j) { if (a[j] < 0) { for (int k = j; k > (i - 1) * 2 + 1; --k) { ++ans; swap(a[k], a[k - 1]); } break; } } for (int j = (i - 1) * 2 + 1; j <= n * 2; ++j) { if (a[j] == -a[(i - 1) * 2 + 1]) { for (int k = j; k > (i - 1) * 2 + 2; --k) { ++ans; swap(a[k], a[k - 1]); } break; } } } return ans; }

Compilation message (stderr)

shoes.cpp: In function 'long long int count_swaps(std::vector<int>)':
shoes.cpp:18:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   18 |     for (int i = 1; i <= n * 2; ++i)
      |     ^~~
shoes.cpp:20:2: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   20 |  ll ans = 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...