Submission #30295

# Submission time Handle Problem Language Result Execution time Memory
30295 2017-07-23T08:04:32 Z ozaslan Gondola (IOI14_gondola) C++14
0 / 100
0 ms 2544 KB
#include "gondola.h"
#include <vector>
#include <algorithm>
#define MOD 1000000009
using namespace std;

int valid(int n, int inputSeq[])
{
	int bayrak = 1;
	for (int i = 0; i < n; i++) {
		if (inputSeq[i] <= n) {
			int sayi = inputSeq[i];
			for(int j = i; j < n; j++, sayi++) {
				if (inputSeq[i] != sayi && inputSeq[i] < n) {
					bayrak = 0;
					break;
				}
			}
		}
	}
    
	return -1;
}

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

int replacement(int n, int gondolaSeq[], int replacementSeq[])
{
  return -2;
}

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

long long us(long long a, long long b) {
	if(b == 1) return a;
	if(b & 1) return (us(a, b>>1) * us(a, b>>1) * a) % MOD;
	return (us(a, b>>1) * us(a, b>>1)) % MOD;
}


int countReplacement(int n, int inputSeq[])
{
	vector<int> v;

	for (int i = 0; i < n; i++)
		if (inputSeq[i] > n) v.push_back(inputSeq[i]);

	sort(v.begin(), v.end());

	long long sonuc = 1;

	if (v.size() == n) sonuc = n;

	int onceki = n; 
	for(int i = 0; i < v.size(); i++) {
		sonuc *= us(v.size()-i, v[i]-onceki);
		sonuc %= MOD;
		onceki = v[i];
	}

	return sonuc % MOD;
}

Compilation message

gondola.cpp: In function 'int valid(int, int*)':
gondola.cpp:9:6: warning: variable 'bayrak' set but not used [-Wunused-but-set-variable]
  int bayrak = 1;
      ^
gondola.cpp: In function 'int countReplacement(int, int*)':
gondola.cpp:52:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  if (v.size() == n) sonuc = n;
               ^
gondola.cpp:55:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i = 0; i < v.size(); i++) {
                   ^
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 2544 KB Integer -1 violates the range [0, 1]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 2544 KB Integer -1 violates the range [0, 1]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 2544 KB Integer -1 violates the range [0, 1]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 2544 KB Integer -2 violates the range [0, 350000]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 2544 KB Integer -2 violates the range [0, 350000]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 2544 KB Integer -2 violates the range [0, 350000]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 2544 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 2544 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 2544 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 2544 KB Output isn't correct
2 Halted 0 ms 0 KB -