답안 #200565

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
200565 2020-02-07T10:25:38 Z mohammad 곤돌라 (IOI14_gondola) C++14
5 / 100
6 ms 380 KB
/*
░░░░██████████████████
░░▄███████▀▀▀▀▀▀███████▄
░▐████▀▒mohammad▒▀██████▄
░███▀▒▒▒▒alaa▒▒▒▒▒▒▀█████
░▐██▒▒▒alwrawrah▒▒▒▒▒████▌
░▐█▌▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒████▌
░░█▒▄▀▀▀▀▀▄▒▒▄▀▀▀▀▀▄▒▐███▌
░░░▐░░░▄▄░░▌▐░░░▄▄░░▌▐███▌
░▄▀▌░░░▀▀░░▌▐░░░▀▀░░▌▒▀▒█▌
░▌▒▀▄░░░░▄▀▒▒▀▄░░░▄▀▒▒▄▀▒▌
░▀▄▐▒▀▀▀▀▒▒▒▒▒▒▀▀▀▒▒▒▒▒▒█
░░░▀▌▒▄██▄▄▄▄████▄▒▒▒▒█▀
░░░░▄██████████████▒▒▐▌
░░░▀███▀▀████▀█████▀▒▌
░░░░░▌▒▒▒▄▒▒▒▄▒▒▒▒▒▒▐
░░░░░▌▒▒▒▒▀▀▀▒▒▒▒▒▒▒▐
*/
 
#include<bits/stdc++.h>
#include "gondola.h"
using namespace std;
 
typedef long long ll ;
const ll oo = 4294967296 ;
const double PI = acos(-1) ;
const ll M = 998244353   ;

map<int,int> mp;
vector<pair<int,int>> v;

int valid(int n, int inputSeq[]){
	// bool b = false ;
	// for(int i = 0 ; i < n ; ++i){
	// 	mp[inputSeq[i]]++;
	// 	if(mp[inputSeq[i]] > 1)return 0;
	// 	if(inputSeq[i] <= n){
	// 		b = 1 ;
	// 		int x = inputSeq[i];
	// 		int f = i - 1;
	// 		while(f > -1 && inputSeq[f] > n){
	// 			x--;
	// 			if(x == 0) x = n;
	// 			inputSeq[f] = x;
	// 			mp[x]++;
	// 			if(mp[x] > 1) return 0 ;
	// 			f--;
	// 		}
	// 		f = i + 1 ;
	// 		x = inputSeq[i];
	// 		while(f < n && inputSeq[f] > n){
	// 			x++;
	// 			if(x == n + 1) x = 1;
	// 			inputSeq[f] = x;
	// 			mp[x]++;
	// 			if(mp[x] > 1)return 0;
	// 			f++;
	// 		}
	// 	}
	// }
	// if(b){
	// 	for(int i = 1 ; i < n ; ++i)
	// 		if((inputSeq[i] == 1 && inputSeq[i - 1] != n) || (inputSeq[i] != 1 && inputSeq[i - 1] + 1 != inputSeq[i])) return 0;
	// }
	return -1 ;
}

//----------------------

int replacement(int n, int gondolaSeq[], int replacementSeq[]){
	bool b = false ;
	for(int i = 0 ; i < n ; ++i){
		mp[gondolaSeq[i]]++;
		if(mp[gondolaSeq[i]] > 1)return 0;
		if(gondolaSeq[i] <= n){
			b = 1;
			int x = gondolaSeq[i];
			int f = i - 1;
			while(f > -1 && gondolaSeq[f] > n){
				x--;
				if(x == 0) x = n;
				v.push_back({gondolaSeq[f] , x});
				gondolaSeq[f] = x;
				mp[x]++;	
				if(mp[x] > 1) return 0 ;
				f--;
			}
			f = i + 1 ;
			x = gondolaSeq[i];
			while(f < n && gondolaSeq[f] > n){
				x++;
				if(x == n + 1) x = 1;
				v.push_back({gondolaSeq[f] , x});
				gondolaSeq[f] = x;
				mp[x]++;
				if(mp[x] > 1)return 0;
				f++;
			}
			i = f - 1;
		}
	}
	int l = 0 , ls = n + 1;
	if(b){
		for(int i = 1 ; i < n ; ++i)
			if((gondolaSeq[i] == 1 && gondolaSeq[i - 1] != n) || (gondolaSeq[i] != 1 && gondolaSeq[i - 1] + 1 != gondolaSeq[i])) return 0;
		sort(v.begin(), v.end());
		for(auto x : v){
			replacementSeq[l++] = x.second;
			while(ls < x.first)
				replacementSeq[l++] =ls++;
			ls++;
		}
	}else{
		sort(gondolaSeq , gondolaSeq + n);
		for(int i = 0 ; i < n ; ++i){
			replacementSeq[l++] = i + 1;
			while(ls < gondolaSeq[i])
				replacementSeq[l++] =ls++;	
			ls++;
		}
	}
	return l ;
}

//----------------------

int countReplacement(int n, int inputSeq[])
{
  return -3;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 376 KB Integer -1 violates the range [0, 1]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 376 KB Integer -1 violates the range [0, 1]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 376 KB Integer -1 violates the range [0, 1]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Correct 5 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 372 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Correct 5 ms 380 KB Output is correct
6 Correct 5 ms 380 KB Output is correct
7 Correct 5 ms 376 KB Output is correct
8 Incorrect 5 ms 376 KB Output isn't correct
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 368 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Correct 5 ms 368 KB Output is correct
6 Correct 5 ms 256 KB Output is correct
7 Correct 6 ms 376 KB Output is correct
8 Incorrect 5 ms 376 KB Output isn't correct
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 376 KB Integer -3 violates the range [0, 1000000008]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 376 KB Integer -3 violates the range [0, 1000000008]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 376 KB Integer -3 violates the range [0, 1000000008]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 376 KB Integer -3 violates the range [0, 1000000008]
2 Halted 0 ms 0 KB -