답안 #30336

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
30336 2017-07-23T08:57:11 Z kavun 곤돌라 (IOI14_gondola) C++14
20 / 100
59 ms 262144 KB
#include "gondola.h"
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
const int mod = 1e9 + 9;
int power(int x, int k)
{
  if(k == 1)
    return x;
  if(k & 1)
    return x*power(x,k-1) % mod;
  else
    {
      int val = power(x,k/2);
      return val*val % mod;
    }
}

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

  set<int> s;
  for(int i = 0; i < n; i++)
    s.insert(inputSeq[i]);
  if(s.size() == n)
    return 1;
  else 
    return 0;
}

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

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

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

int countReplacement(int n, int inputSeq[])
{
  if(!valid(n,inputSeq))
    return 0;
  int ans = 1;
  set<int> rep;
  for(int i = 0; i < n; i++)
    if(inputSeq[i] > n)
      rep.insert(inputSeq[i]);
  int before = n, cnt = 0;
  for(set<int>::iterator it = rep.begin(); it != rep.end(); it++)
    {
      int x = *it;
      ans = (ll) ans * power(rep.size() - cnt, x - before - 1) % mod;
      before = x;
      cnt++;
    }
  sort(inputSeq, inputSeq+n);
  if(inputSeq[0] > n)
    ans = (ll)ans * n % mod;
  return ans;
}

Compilation message

gondola.cpp: In function 'int valid(int, int*)':
gondola.cpp:37:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   if(s.size() == n)
               ^
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 3388 KB Output is correct
2 Correct 0 ms 3388 KB Output is correct
3 Correct 0 ms 3388 KB Output is correct
4 Correct 0 ms 3388 KB Output is correct
5 Correct 0 ms 3388 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 3388 KB Output is correct
2 Correct 0 ms 3388 KB Output is correct
3 Correct 0 ms 3388 KB Output is correct
4 Correct 0 ms 3388 KB Output is correct
5 Correct 0 ms 3388 KB Output is correct
6 Correct 9 ms 5104 KB Output is correct
7 Correct 13 ms 3388 KB Output is correct
8 Correct 33 ms 6688 KB Output is correct
9 Correct 6 ms 4444 KB Output is correct
10 Correct 33 ms 7348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 3388 KB Output is correct
2 Correct 0 ms 3388 KB Output is correct
3 Correct 0 ms 3388 KB Output is correct
4 Correct 0 ms 3388 KB Output is correct
5 Correct 0 ms 3388 KB Output is correct
6 Correct 16 ms 5104 KB Output is correct
7 Correct 16 ms 3388 KB Output is correct
8 Correct 19 ms 6688 KB Output is correct
9 Correct 3 ms 4444 KB Output is correct
10 Correct 29 ms 7348 KB Output is correct
11 Correct 0 ms 3388 KB Output is correct
12 Correct 0 ms 3388 KB Output is correct
13 Correct 6 ms 3388 KB Output is correct
14 Correct 0 ms 3388 KB Output is correct
15 Correct 9 ms 3388 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 3388 KB Integer -2 violates the range [0, 350000]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 3388 KB Integer -2 violates the range [0, 350000]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 3388 KB Integer -2 violates the range [0, 350000]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Memory limit exceeded 43 ms 262144 KB Memory limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Memory limit exceeded 59 ms 262144 KB Memory limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Memory limit exceeded 43 ms 262144 KB Memory limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Memory limit exceeded 49 ms 262144 KB Memory limit exceeded
2 Halted 0 ms 0 KB -