제출 #702149

#제출 시각아이디문제언어결과실행 시간메모리
702149mychecksedad곤돌라 (IOI14_gondola)C++17
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h>
#include <gondola.h>
using namespace std;


int valid(int n, int a[]){
	map<int, bool> m;
	for(int i = 0; i < n; ++i){
		if(m[a[i]]){
			return 0;
		}
		m[a[i]] = 1;
	}
	int mn = -1;
	for(int i = 0; i < n; ++i){
		if(a[i] <= n){
			mn = mn == -1 ? i : (a[mn] < a[i] ? mn : i);
		}
	}
	if(mn == -1) return 1;
	int s = a[mn];
	bool ok = 1;
	for(int i = mn; i != mn || ok; (i += 1) %= n, s++){
		if(s == n + 1) s = 1;
		ok = 0;
		if(a[i] <= n && a[i] != s){
			return 0;
		}
	}
	return 1;
}

int replacement(int n, int a[], int r[]){
	int l = 0, mn = -1;
	for(int i = 0; i < n; ++i){
		if(a[i] <= n){
			mn = mn == -1 ? i : (a[mn] < a[i] ? mn : i);
		}
	}
	if(mn == -1) return 1;
	int s = a[mn];
	bool ok = 1;
	queue<pair<int, int>> s;
	for(int i = mn; i != mn || ok; (i += 1) %= n, s++){
		if(s == n + 1) s = 1;
		ok = 0;
		if(a[i] > n){
			s.insert({a[i], i});
		}
	}
	for(int i = n + 1; !s.empty(); ++i){
		auto v = *s.begin();
		s.erase(s.begin());
		while(i < v.first){
			r[l] = a[v.second];
			a[v.second] = i;
			l++;
			i++;
		}
	}
	return l;
}

int countReplacement(int n, int inputSeq[]){
	return -1;
}

컴파일 시 표준 에러 (stderr) 메시지

gondola.cpp: In function 'int replacement(int, int*, int*)':
gondola.cpp:43:24: error: conflicting declaration 'std::queue<std::pair<int, int> > s'
   43 |  queue<pair<int, int>> s;
      |                        ^
gondola.cpp:41:6: note: previous declaration as 'int s'
   41 |  int s = a[mn];
      |      ^
gondola.cpp:48:6: error: request for member 'insert' in 's', which is of non-class type 'int'
   48 |    s.insert({a[i], i});
      |      ^~~~~~
gondola.cpp:51:24: error: request for member 'empty' in 's', which is of non-class type 'int'
   51 |  for(int i = n + 1; !s.empty(); ++i){
      |                        ^~~~~
gondola.cpp:52:15: error: request for member 'begin' in 's', which is of non-class type 'int'
   52 |   auto v = *s.begin();
      |               ^~~~~
gondola.cpp:53:5: error: request for member 'erase' in 's', which is of non-class type 'int'
   53 |   s.erase(s.begin());
      |     ^~~~~
gondola.cpp:53:13: error: request for member 'begin' in 's', which is of non-class type 'int'
   53 |   s.erase(s.begin());
      |             ^~~~~