Submission #298319

# Submission time Handle Problem Language Result Execution time Memory
298319 2020-09-12T17:24:04 Z FlashGamezzz Carnival (CEOI14_carnival) Java 11
Compilation error
0 ms 0 KB
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <set>
#include <map>

using namespace std;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n, count = 2, prefs[155], vals[155];
	cin >> n;
	prefs[0] = 1;
	string s = "1";
	for (int i = 1; i < n; i++) {
		s += " " + to_string(i+1);
		cout << i+1 << " " << s << endl;
		cin >> prefs[i];
	}
	vals[0] = 1;
	for (int i = 1; i < n; i++) {
		if (prefs[i] == prefs[i-1]+1) {
			vals[i] = count;
			count++;
		}
	}
	vector<int> nums;
	for (int i = 0; i < n; i++) {
		if (vals[i] == 0) {
			vector<int> temp;
			for (int a : nums){
				temp.push_back(a);
			}
			while (temp.size() > 1) {
				int ind = rand() % temp.size(), v = temp[ind], in;
				cout << 2 << " " << v << " " << (i+1) << endl;
				cin >> in;
				if (in == 1) {
					vals[i] = v;
					break;
				}
				temp.erase(temp.begin() + ind);
			}
			if (vals[i] == 0) {
				vals[i] = temp[0];
			}
		} else {
			nums.push_back(vals[i]);
		}
	}
	cout << 0;
	for (int i = 0; i < n; i++) {
		cout << " " << vals[i];
	}
	cout << endl;
	return 0;
}

Compilation message

carnival.java:1: error: illegal character: '#'
#include <iostream>
^
carnival.java:1: error: class, interface, or enum expected
#include <iostream>
         ^
carnival.java:2: error: illegal character: '#'
#include <cstdlib>
^
carnival.java:3: error: illegal character: '#'
#include <cstdio>
^
carnival.java:4: error: illegal character: '#'
#include <fstream>
^
carnival.java:5: error: illegal character: '#'
#include <algorithm>
^
carnival.java:6: error: illegal character: '#'
#include <string>
^
carnival.java:7: error: illegal character: '#'
#include <utility>
^
carnival.java:8: error: illegal character: '#'
#include <vector>
^
carnival.java:9: error: illegal character: '#'
#include <queue>
^
carnival.java:10: error: illegal character: '#'
#include <set>
^
carnival.java:11: error: illegal character: '#'
#include <map>
^
carnival.java:15: error: class, interface, or enum expected
int main() {
^
carnival.java:17: error: class, interface, or enum expected
	cin.tie(NULL);
	^
carnival.java:18: error: class, interface, or enum expected
	int n, count = 2, prefs[155], vals[155];
	^
carnival.java:19: error: class, interface, or enum expected
	cin >> n;
	^
carnival.java:20: error: class, interface, or enum expected
	prefs[0] = 1;
	^
carnival.java:21: error: class, interface, or enum expected
	string s = "1";
	^
carnival.java:22: error: class, interface, or enum expected
	for (int i = 1; i < n; i++) {
	^
carnival.java:22: error: class, interface, or enum expected
	for (int i = 1; i < n; i++) {
	                ^
carnival.java:22: error: class, interface, or enum expected
	for (int i = 1; i < n; i++) {
	                       ^
carnival.java:24: error: class, interface, or enum expected
		cout << i+1 << " " << s << endl;
		^
carnival.java:25: error: class, interface, or enum expected
		cin >> prefs[i];
		^
carnival.java:26: error: class, interface, or enum expected
	}
	^
carnival.java:28: error: class, interface, or enum expected
	for (int i = 1; i < n; i++) {
	^
carnival.java:28: error: class, interface, or enum expected
	for (int i = 1; i < n; i++) {
	                ^
carnival.java:28: error: class, interface, or enum expected
	for (int i = 1; i < n; i++) {
	                       ^
carnival.java:31: error: class, interface, or enum expected
			count++;
			^
carnival.java:32: error: class, interface, or enum expected
		}
		^
carnival.java:35: error: class, interface, or enum expected
	for (int i = 0; i < n; i++) {
	^
carnival.java:35: error: class, interface, or enum expected
	for (int i = 0; i < n; i++) {
	                ^
carnival.java:35: error: class, interface, or enum expected
	for (int i = 0; i < n; i++) {
	                       ^
carnival.java:38: error: class, interface, or enum expected
			for (int a : nums){
			^
carnival.java:40: error: class, interface, or enum expected
			}
			^
carnival.java:43: error: class, interface, or enum expected
				cout << 2 << " " << v << " " << (i+1) << endl;
				^
carnival.java:44: error: class, interface, or enum expected
				cin >> in;
				^
carnival.java:45: error: class, interface, or enum expected
				if (in == 1) {
				^
carnival.java:47: error: class, interface, or enum expected
					break;
					^
carnival.java:48: error: class, interface, or enum expected
				}
				^
carnival.java:50: error: class, interface, or enum expected
			}
			^
carnival.java:53: error: class, interface, or enum expected
			}
			^
carnival.java:56: error: class, interface, or enum expected
		}
		^
carnival.java:59: error: class, interface, or enum expected
	for (int i = 0; i < n; i++) {
	^
carnival.java:59: error: class, interface, or enum expected
	for (int i = 0; i < n; i++) {
	                ^
carnival.java:59: error: class, interface, or enum expected
	for (int i = 0; i < n; i++) {
	                       ^
carnival.java:61: error: class, interface, or enum expected
	}
	^
carnival.java:63: error: class, interface, or enum expected
	return 0;
	^
carnival.java:64: error: class, interface, or enum expected
}
^
48 errors