답안 #72911

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
72911 2018-08-27T08:18:11 Z nvmdava 곤돌라 (IOI14_gondola) C++17
25 / 100
76 ms 5116 KB
#include "gondola.h"
#include <bits/stdc++.h>
using namespace std;
 
struct Gondola{
	int id, val;
	Gondola(int _id, int _val){
		id = _id;
		val = _val;
	}
	bool operator<(const Gondola& rhs) const{
		val < rhs.val;
	}
};
 
int ord[100001];
map<int, int> in;
vector<Gondola> v;
 
 
int valid(int n, int inputSeq[]){
	int i;
	for(i = 0; i < n; i++){
		if(in[inputSeq[i]]) return 0;
		in[inputSeq[i]] = 1;
	}
	for(i = 0; i < n; i++){
		if(inputSeq[i] <= n) break;
	}
	if(i == n) return 1;
	int k = inputSeq[i] - 1;
	for(int j = 0; j < n; j++){
		ord[(k + j) % n] = inputSeq[(i + j) % n];
		if((ord[(k + j) % n] != (k + j) % n + 1 && ord[(k + j) % n] <= n) || ord[(k + j) % n] < 1) return 0;
	}
	for(i = 0; i < n; i++){
		if((ord[i] != i + 1 && ord[i] <= n) || ord[i] < 1) return 0;
	}
	return 1;
}
 
//----------------------
 
int replacement(int n, int gondolaSeq[], int replacementSeq[]){
	int i;
	for(i = 0; i < n; i++){
		if(gondolaSeq[i] <= n) break;
	}
	int k;
	if(i == n){
		i = 0;
		k = 0;
	} else {
		k = gondolaSeq[i] - 1;	
	}
	for(int j = 0; j < n; j++){
		v.push_back(Gondola((k + j) % n + 1, gondolaSeq[(i + j) % n]));
	}
	sort(v.begin(), v.end());
	i = 0;
	int s = n + 1;
	for(auto x : v){
		if(x.val <= n) continue;
		replacementSeq[i] = x.id;
		i++;
		for(; s < x.val; s++){
			replacementSeq[i] = s;
			i++;
		}
		s = x.val + 1;
	}
	return i;
}
 
//----------------------
 
int countReplacement(int n, int inputSeq[]){
	int i;
	for(i = 0; i < n; i++){
		if(inputSeq[i] <= n) break;
	}
	int k;
	if(i == n){
		i = 0;
		k = 0;
	} else {
		k = inputSeq[i] - 1;	
	}
	for(int j = 0; j < n; j++){
		ord[(k + j) % n] = inputSeq[(i + j) % n];
	}
}

Compilation message

gondola.cpp: In member function 'bool Gondola::operator<(const Gondola&) const':
gondola.cpp:12:7: warning: statement has no effect [-Wunused-value]
   val < rhs.val;
   ~~~~^~~~~~~~~
gondola.cpp:13:2: warning: no return statement in function returning non-void [-Wreturn-type]
  }
  ^
gondola.cpp: In function 'int countReplacement(int, int*)':
gondola.cpp:92:1: warning: no return statement in function returning non-void [-Wreturn-type]
 }
 ^
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 3 ms 356 KB Output is correct
3 Correct 2 ms 356 KB Output is correct
4 Correct 2 ms 432 KB Output is correct
5 Correct 2 ms 512 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 512 KB Output is correct
2 Correct 3 ms 512 KB Output is correct
3 Correct 2 ms 512 KB Output is correct
4 Correct 2 ms 584 KB Output is correct
5 Correct 2 ms 584 KB Output is correct
6 Correct 24 ms 2632 KB Output is correct
7 Correct 17 ms 2632 KB Output is correct
8 Correct 38 ms 4456 KB Output is correct
9 Correct 13 ms 4456 KB Output is correct
10 Correct 53 ms 5100 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 5100 KB Output is correct
2 Correct 2 ms 5100 KB Output is correct
3 Correct 2 ms 5100 KB Output is correct
4 Correct 2 ms 5100 KB Output is correct
5 Correct 3 ms 5100 KB Output is correct
6 Correct 22 ms 5100 KB Output is correct
7 Correct 15 ms 5100 KB Output is correct
8 Correct 38 ms 5100 KB Output is correct
9 Correct 12 ms 5100 KB Output is correct
10 Correct 52 ms 5116 KB Output is correct
11 Correct 2 ms 5116 KB Output is correct
12 Correct 2 ms 5116 KB Output is correct
13 Correct 29 ms 5116 KB Output is correct
14 Correct 2 ms 5116 KB Output is correct
15 Correct 76 ms 5116 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 5116 KB Output is correct
2 Correct 3 ms 5116 KB Output is correct
3 Correct 2 ms 5116 KB Output is correct
4 Correct 3 ms 5116 KB Output is correct
5 Correct 3 ms 5116 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 5116 KB Output is correct
2 Correct 2 ms 5116 KB Output is correct
3 Correct 3 ms 5116 KB Output is correct
4 Correct 2 ms 5116 KB Output is correct
5 Correct 3 ms 5116 KB Output is correct
6 Correct 2 ms 5116 KB Output is correct
7 Incorrect 5 ms 5116 KB Output isn't correct
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 5116 KB Output is correct
2 Correct 2 ms 5116 KB Output is correct
3 Correct 4 ms 5116 KB Output is correct
4 Correct 2 ms 5116 KB Output is correct
5 Correct 3 ms 5116 KB Output is correct
6 Correct 3 ms 5116 KB Output is correct
7 Incorrect 4 ms 5116 KB Output isn't correct
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 5116 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 5116 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 5116 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 5116 KB Output isn't correct
2 Halted 0 ms 0 KB -