CSES - Datatähti 2015 loppu - Results
Submission details
Task:Urkupillit
Sender:Dentosal
Submission time:2015-01-29 17:14:11 +0200
Language:C++
Status:COMPILE ERROR

Compiler report

input/code.cpp: In function 'int main()':
input/code.cpp:34:38: error: request for member 'begin' in 'urut', which is of non-class type 'unsigned int [100001]'
  while (!isDone) random_shuffle(urut.begin(), urut.begin()+n);
                                      ^
input/code.cpp:34:52: error: request for member 'begin' in 'urut', which is of non-class type 'unsigned int [100001]'
  while (!isDone) random_shuffle(urut.begin(), urut.begin()+n);
                                                    ^

Code

#include <iostream>
#include <algorithm>
#include <cmath>

using namespace std;

unsigned int urut[100001];
unsigned int n;
unsigned int k;

inline bool isDone() {
	unsigned int pairs=0;
	if (n<2) {return 0;}
	for (unsigned int i=1; i<n; ++i) {
		if (urut[i-1]>urut[i]) {
			++pairs;
		}
	}
	return (pairs==k);
}



int main() {
	cin >> n;
	cin >> k;


	for (unsigned int i = 0; i < n; ++i) {
		urut[i] = i+1;
	}


	while (!isDone) random_shuffle(urut.begin(), urut.begin()+n);



	for (unsigned int i=0; i<n; ++i){cout << urut[i]+1 << " ";}
	cout << endl;




	return 0;
}