Submission #441485

#TimeUsernameProblemLanguageResultExecution timeMemory
441485QuantumK9Arranging Shoes (IOI19_shoes)C++17
50 / 100
1092 ms146460 KiB
#include "shoes.h" #include <bits/stdc++.h> using namespace std; #define ll long long #define pb push_back #define mp make_pair map<int, queue<int> > rgt; long long count_swaps(vector<int> s) { //nums ll n = s.size()/2; ll S = s.size(); //iterate through s -- preprocess for( int i = 0; i < S; i++ ){ rgt[ s[i] ].push(i); } bool idim[S]; memset( idim, true, sizeof idim ); //process ll grand = 0; for( int i = 0; i < S; i++ ){ if( idim[i] ){ idim[i] = false; rgt[ s[i] ].pop(); //move partner ll val = rgt[ -s[i] ].front(); for( int j = 0; j < val; j++ ){ grand += idim[j]; } idim[val] = false; rgt[ -s[i] ].pop(); if( s[i] > 0 ){ grand++; } } } return grand; }

Compilation message (stderr)

shoes.cpp: In function 'long long int count_swaps(std::vector<int>)':
shoes.cpp:14:5: warning: unused variable 'n' [-Wunused-variable]
   14 |  ll n = s.size()/2;
      |     ^
#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...