CSES - Datatähti 2017 alku - Results
Submission details
Task:Järjestys
Sender:ankka22
Submission time:2016-10-14 15:02:53 +0300
Language:C++
Status:READY
Result:0
Feedback
groupverdictscore
#10
#20
#30
Test results
testverdicttimegroup
#10.05 s1details
#20.06 s2details
#30.08 s3details

Compiler report

input/code.cpp: In function 'int main()':
input/code.cpp:14:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  while (c < 5*v.size()) {
                      ^
input/code.cpp:22:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    while (i < v.size()) {
                      ^
input/code.cpp:38:29: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (int i = 0; i < s.size(); i++) {
                             ^

Code

#include <iostream>
#include <algorithm>
int main() {
	int n;
	std::vector<int> v;
  std::vector<int> s;
	std::cin >> n;
  for (int i = 0; i < n; i++) {
    int t;
    std::cin >> t;
    v.push_back(t);
  }
	int c = 0;
	while (c < 5*v.size()) {
		if (v.at(0) != 1) {
			s.push_back(v.at(0));
			std::swap(v[0],v[v.at(0) - 1]);
		}
		else {
			bool ready = true;
			int i = 1;
			while (i < v.size()) {
				if (v.at(i) != i + 1) {
					s.push_back(i + 1);
					std::swap(v[0], v[i]);
					ready = false;
					break;
				}
				i++;
			}
			if (ready) {
				break;
			}
		}
		c++;
	}
	std::cout << c << std::endl;
	for (int i = 0; i < s.size(); i++) {
		std::cout << s.at(i) << " ";
	}
	std::cout << std::endl;
	return 0;
}

Test details

Test 1

Group: 1

Verdict:

input
10
9 3 4 7 6 5 10 2 8 1

correct output
32
10 10 9 10 9 8 7 9 4 2 1 4 5 2...

user output
10
9 8 2 3 4 7 10 5 6 5 

Test 2

Group: 2

Verdict:

input
1000
650 716 982 41 133 1000 876 92...

correct output
3984
207 207 206 207 128 127 126 12...

user output
1000
650 328 760 478 737 281 696 98...

Test 3

Group: 3

Verdict:

input
100000
94703 47808 62366 31885 7091 8...

correct output
399956
98676 98676 98675 98676 62994 ...

user output
100008
94703 71577 78918 31721 46072 ...