Submission #684105

# Submission time Handle Problem Language Result Execution time Memory
684105 2023-01-20T12:00:28 Z Dulguun Arranging Shoes (IOI19_shoes) C++14
10 / 100
1 ms 340 KB
#include<bits/stdc++.h>
using namespace std;

long long count_swaps(vector<int> s){
	map<int, vector<int> > m;
	int l=s.size(), n=(s.size()+1)/2;
	long long sum=0;
	for(int i=0; i<l; i++){
		m[s[i]].push_back(i);
	}
	for(int i=0; i<l; i++){
		if(s[i]==0) continue;
		sum+=m[-s[i]][0]-i-1;
		if(s[i]>0) sum++;
		s[m[-s[i]][0]]=0;
		m[-s[i]].erase(m[-s[i]].begin());
	}
	return sum;
}

Compilation message

shoes.cpp: In function 'long long int count_swaps(std::vector<int>)':
shoes.cpp:6:18: warning: unused variable 'n' [-Wunused-variable]
    6 |  int l=s.size(), n=(s.size()+1)/2;
      |                  ^
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 296 KB Output is correct
6 Correct 1 ms 300 KB Output is correct
7 Incorrect 1 ms 212 KB Output isn't correct
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Incorrect 1 ms 212 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 1 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 296 KB Output is correct
6 Correct 1 ms 300 KB Output is correct
7 Incorrect 1 ms 212 KB Output isn't correct
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 296 KB Output is correct
6 Correct 1 ms 300 KB Output is correct
7 Incorrect 1 ms 212 KB Output isn't correct
8 Halted 0 ms 0 KB -