답안 #298355

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
298355 2020-09-12T18:03:24 Z FlashGamezzz 사육제 (CEOI14_carnival) Java 11
컴파일 오류
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>
#include <cassert>
 
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) {
			for (int j = 1; j < nums.size(); j++){
              	int in;
				cout << 2 << " " << nums[j] << " " << (i+1) << endl;
				cin >> in;
				if (in == 1) {
					vals[i] = vals[nums[j]-1];
					break;
				}
			}
			if (vals[i] == 0) {
				vals[i] = vals[nums[0]-1];
			}
		} else {
			nums.push_back(i+1);
		}
	}
	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:12: error: illegal character: '#'
#include <cassert>
^
carnival.java:16: error: class, interface, or enum expected
int main() {
^
carnival.java:18: error: class, interface, or enum expected
	cin.tie(NULL);
	^
carnival.java:19: error: class, interface, or enum expected
	int n, count = 2, prefs[155], vals[155] = {};
	^
carnival.java:20: error: class, interface, or enum expected
	cin >> n;
	^
carnival.java:21: error: class, interface, or enum expected
	prefs[0] = 1;
	^
carnival.java:22: error: class, interface, or enum expected
	string s = "1";
	^
carnival.java:23: error: class, interface, or enum expected
	for (int i = 1; i < n; i++) {
	^
carnival.java:23: error: class, interface, or enum expected
	for (int i = 1; i < n; i++) {
	                ^
carnival.java:23: error: class, interface, or enum expected
	for (int i = 1; i < n; i++) {
	                       ^
carnival.java:25: error: class, interface, or enum expected
		cout << i+1 << " " << s << endl;
		^
carnival.java:26: error: class, interface, or enum expected
		cin >> prefs[i];
		^
carnival.java:27: error: class, interface, or enum expected
	}
	^
carnival.java:29: error: class, interface, or enum expected
	for (int i = 1; i < n; i++) {
	^
carnival.java:29: error: class, interface, or enum expected
	for (int i = 1; i < n; i++) {
	                ^
carnival.java:29: error: class, interface, or enum expected
	for (int i = 1; i < n; i++) {
	                       ^
carnival.java:32: error: class, interface, or enum expected
			count++;
			^
carnival.java:33: error: class, interface, or enum expected
		}
		^
carnival.java:36: error: class, interface, or enum expected
	for (int i = 0; i < n; i++) {
	^
carnival.java:36: error: class, interface, or enum expected
	for (int i = 0; i < n; i++) {
	                ^
carnival.java:36: error: class, interface, or enum expected
	for (int i = 0; i < n; i++) {
	                       ^
carnival.java:38: error: class, interface, or enum expected
			for (int j = 1; j < nums.size(); j++){
			                ^
carnival.java:38: error: class, interface, or enum expected
			for (int j = 1; j < nums.size(); j++){
			                                 ^
carnival.java:40: error: class, interface, or enum expected
				cout << 2 << " " << nums[j] << " " << (i+1) << endl;
				^
carnival.java:41: error: class, interface, or enum expected
				cin >> in;
				^
carnival.java:42: error: class, interface, or enum expected
				if (in == 1) {
				^
carnival.java:44: error: class, interface, or enum expected
					break;
					^
carnival.java:45: error: class, interface, or enum expected
				}
				^
carnival.java:49: error: class, interface, or enum expected
			}
			^
carnival.java:52: error: class, interface, or enum expected
		}
		^
carnival.java:55: error: class, interface, or enum expected
	for (int i = 0; i < n; i++) {
	^
carnival.java:55: error: class, interface, or enum expected
	for (int i = 0; i < n; i++) {
	                ^
carnival.java:55: error: class, interface, or enum expected
	for (int i = 0; i < n; i++) {
	                       ^
carnival.java:57: error: class, interface, or enum expected
	}
	^
carnival.java:59: error: class, interface, or enum expected
	return 0;
	^
carnival.java:60: error: class, interface, or enum expected
}
^
48 errors