Submission #923257

#TimeUsernameProblemLanguageResultExecution timeMemory
923257Roumak77Arranging Shoes (IOI19_shoes)C++17
50 / 100
1097 ms3260 KiB
#pragma GCC optimize ("O3") #pragma GCC optimize ("unroll-loops") #pragma GCC optimize("-Ofast") #include <bits/stdc++.h> #include <algorithm> #include <iostream> #include <vector> #include <limits> #include <cmath> #include <stack> #include <queue> #include <map> #include <math.h> using namespace std; using ll = long long; int64_t count_swaps(vector<int> shoes){ ll length = shoes.size(); vector<bool> list_n(length, 0); ll total = 0; for(int i = 0; i < length; i++){ if(list_n[i] == 1){ continue; } ll curr_counter = 0; ll curr_val = shoes[i]; if(curr_val > 0){ curr_counter++; } for(int j = i + 1; j < length; j++){ //cout << curr_counter << ", i = " << i << ", j = " << j << endl; if(shoes[j] == -1 * curr_val && list_n[j] == 0){ list_n[j] = 1; break; }else{ if(list_n[j] == 0){ curr_counter++; } } } list_n[i] = 1; //cout << "curr_counter = " << curr_counter << ", i = " << i << endl; total += curr_counter; /*for(int k = 0; k < length; k++){ cout << list_n[k] << " "; } cout << endl; */ } return total; }
#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...