Submission #1039977

#TimeUsernameProblemLanguageResultExecution timeMemory
1039977LaMatematica14Arranging Shoes (IOI19_shoes)C++17
10 / 100
1101 ms140112 KiB
#include <bits/stdc++.h> using namespace std; long long count_swaps(vector<int> S) { int n = S.size(); vector<queue<long long>> a(n); vector<long long> pa(n); long long tot = 0; long long att = 0; for (long long i = 0; i < n; i++) { if (S[i] < 0) { pa[i] = att; a[-S[i]].push(att); att += 2; } } for (long long i = 0; i < n; i++) { if (S[i] > 0) { pa[i] = a[S[i]].front()+1; a[S[i]].pop(); } } for (long long i = 0; i < n; i++) { for (long long j = i+1; j < n; j++) { if (pa[i] > pa[j]) tot++; } } return tot; }
#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...