# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
282841 | 2020-08-25T04:23:08 Z | suren | Arranging Shoes (IOI19_shoes) | C++14 | 1000 ms | 256 KB |
#include<bits/stdc++.h> using namespace std; #define ll long long #define mk make_pair #define pb push_back #define F first #define S second int count_swaps( vector < int > vc ){ int ans = 0, i; int flag = true; for( i = 1; i < vc.size(); i ++ ){ if( abs( vc[i] ) != abs( vc[i-1] ) ){ flag = false; break; } } if( flag == true ){ for(;;); vector < int > srg; vector < int > eyrg; for( i = 0; i < vc.size(); i ++ ){ if( vc[i] < 0 ) srg.pb( i ); if( vc[i] > 0 ) eyrg.pb( i ); } reverse( srg.begin(), srg.end() ); reverse( eyrg.begin(), eyrg.end() ); for( i = 0; i < vc.size(); i ++ ){ if( vc[i] == 0 ) continue; if( vc[ i ] < 0 ){ ans += eyrg[ eyrg.size() - 1 ] - i; vc[ eyrg[ eyrg.size() - 1 ] ] = 0; eyrg.pop_back(); } else{ ans += srg[ srg.size() - 1 ] - i; vc[ srg[ srg.size() - 1 ] ] = 0; srg.pop_back(); } } return ans; } while( vc.size() > 0 ){ for( i = 1; i < vc.size(); i ++ ){ if( vc[i] == vc[0] * -1 ){ if( vc[i] < 0 ){ ans += i; vc.erase( vc.begin() + i ); vc.erase( vc.begin() + 0 ); break; } else{ ans += i-1; vc.erase( vc.begin() + i ); vc.erase( vc.begin() + 0 ); break; } } } } return ans; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1084 ms | 256 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1084 ms | 256 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1084 ms | 256 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1090 ms | 256 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1084 ms | 256 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1084 ms | 256 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |