답안 #902782

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
902782 2024-01-11T02:43:57 Z Muhammad_Aneeq 곤돌라 (IOI14_gondola) C++17
25 / 100
29 ms 5324 KB
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include "gondola.h"
using namespace std;
int valid(int n, int inputSeq[])
{
	vector<pair<int,int>>s={};
	map<int,int>d;
	for (int i=0;i<n;i++)
	{
		d[inputSeq[i]]++;
		if (inputSeq[i]<=n)
			s.push_back({inputSeq[i],i});
	}
	for (auto i:d)
	{
		if (i.second>1)
			return 0;
	}
	for (int i=0;i<s.size()-1;i++)
	{
		int z=s[i+1].second-s[i].second;
		if (((s[i+1].first-z+n-1)%n)+1==s[i].first)
			continue;
		return 0;
	}	
	return 1;
}
int replacement(int n, int gondolaSeq[], int replacementSeq[])
{
	int z=0;
	map<int,int>d;
	for (int i=0;i<n;i++)	
	{
		d[gondolaSeq[i]]++;
		z=max(z,gondolaSeq[i]);
	}
	vector<int>f;
	for (int i=1;i<z;i++)
	{
		if (d.find(i)==d.end())
			f.push_back(i);
		else
		{
			if (d[i]>1)
				return 0;
		}
	}
	for (int i=0;i<f.size();i++)
		replacementSeq[i]=f[i];
	return f.size();
}
int countReplacement(int n, int inputSeq[])
{
	return 0;
}

Compilation message

gondola.cpp: In function 'int valid(int, int*)':
gondola.cpp:22:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |  for (int i=0;i<s.size()-1;i++)
      |               ~^~~~~~~~~~~
gondola.cpp: In function 'int replacement(int, int*, int*)':
gondola.cpp:51:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   51 |  for (int i=0;i<f.size();i++)
      |               ~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 8 ms 2520 KB Output is correct
7 Correct 26 ms 4260 KB Output is correct
8 Correct 16 ms 4820 KB Output is correct
9 Correct 6 ms 1748 KB Output is correct
10 Correct 22 ms 5324 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 8 ms 2516 KB Output is correct
7 Correct 21 ms 4496 KB Output is correct
8 Correct 16 ms 4816 KB Output is correct
9 Correct 5 ms 1752 KB Output is correct
10 Correct 19 ms 5260 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 16 ms 2136 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 29 ms 5276 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 444 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Incorrect 1 ms 348 KB Output isn't correct
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 612 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 1 ms 352 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Incorrect 1 ms 348 KB Output isn't correct
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -