Code Submission Evaluation System Login

Datatähti 2016 alku

Start:2015-09-28 00:00:00
End:2015-10-12 00:00:00
 

Tasks | Scoreboard | Statistics


CSES - Datatähti 2016 alku - Results
History
2015-10-01 19:10:360
2015-10-01 18:52:120
2015-10-01 18:51:0118
2015-10-01 18:48:090
2015-10-01 18:46:4818
2015-10-01 17:56:590
2015-10-01 17:53:250
2015-10-01 17:47:580
2015-10-01 17:44:590
2015-10-01 17:07:190
2015-10-01 16:33:200
2015-10-01 16:23:150
2015-10-01 16:08:540
2015-10-01 16:05:170
2015-10-01 16:04:400
2015-10-01 16:03:330
2015-10-01 14:50:280
2015-10-01 14:29:290
2015-10-01 14:26:55
2015-10-01 14:25:38
Task:Kirjat
Sender:Hoxy
Submission time:2015-10-01 14:26:55
Language:C++
Status:COMPILE ERROR

Compiler report

input/code.cpp: In function 'int main(int, char**)':
input/code.cpp:17:38: error: 'memset' was not declared in this scope
  memset(inuse, -1, amount*sizeof(int));
                                      ^

Code

#include <iostream>

using namespace std;

int SeuraavaVapaa(int i, int i2, int* inuse, int amount);

int main(int argc, char *argv[]) {

	ios_base::sync_with_stdio(0);

	int amount = 0;
	cin >> amount;
	int* uolevi = new int[amount];
	int* maija = new int[amount];
	int* kaaleppi = new int[amount];
	int* inuse = new int[amount];
	memset(inuse, -1, amount*sizeof(int));
	for(int i = 0; i < amount; i++)
		cin >> uolevi[i];
	for(int i = 0; i < amount; i++)
		cin >> maija[i];

	for(int i = 0; i < amount; i++) {

		int next = SeuraavaVapaa(uolevi[i], maija[i], inuse, amount);
		kaaleppi[i] = next;
		inuse[next] = i;
	}

	for(int i = 0; i < amount; i++) {

		cout << kaaleppi[i] << " ";
	}

	return 0;
}

int SeuraavaVapaa(int i, int i2, int* inuse, int amount) {

	for(int i3 = 0; i3 < amount; i3++) {
		if(i3 == i || i3 == i2) continue;

		if(inuse[i3] == -1)
			return i3;
	}

	return -1;
}