CODE FESTIVAL 2016 qual C

Submission #1330763

Source codeソースコード

#include<stdio.h>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<utility>
#include<memory>
#include<cmath>

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define pb push_back

using namespace std;
 
typedef long long ll;
typedef pair<int,int> P;
const int mod=1e9+7,INF=1<<30;
const double EPS=1e-12,PI=3.1415926535897932384626;
const int MAX_N=100003;
const ll LINF=100000000000000000;

ll ub[MAX_N],det[MAX_N],t[MAX_N],a[MAX_N];

int main(){
  int N;
  cin >> N ;
  REP(i,1,N+1) scanf("%lld",&t[i]);
  REP(i,0,N) scanf("%lld",&a[i]);
  t[0]=0;
  a[N]=LINF;
  fill(det,det+N,0);
  fill(ub,ub+N,LINF);
  bool ok=true;
  rep(i,N){
    if(t[i+1]!=t[i]) det[i]=t[i+1];
    else ub[i]=t[i+1];
  }
  for(int i=N-1;i>=0;i--){
    if(a[i+1]!=a[i]){
      if(det[i]!=0 && det[i]!=a[i]){
        ok=false;
        break;
      }
      else det[i]=a[i];
    }else{
      ub[i]=min(ub[i],a[i]);
    }
  }
  if(!ok) cout << "0" << endl;
  ll cnt=1;
  rep(i,N){
    if(det[i]==0){
      cnt=(cnt*ub[i])%mod;
    }
  }
  if(ok) cout << cnt << endl;
  return 0;
}

Submission

Task問題 C - 二人のアルピニスト / Two Alpinists
User nameユーザ名 Po
Created time投稿日時
Language言語 C++14 (GCC 5.4.1)
Status状態 WA
Score得点 0
Source lengthソースコード長 1319 Byte
File nameファイル名
Exec time実行時間 ms
Memory usageメモリ使用量 -

Compiler messageコンパイルメッセージ

./Main.cpp: In function ‘int main()’:
./Main.cpp:34:35: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
REP(i,1,N+1) scanf("%lld",&t[i]);
^
./Main.cpp:35:33: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
REP(i,0,N) scanf("%lld",&a[i]);
^

Test case

Set

Set name Score得点 / Max score Cases
Sample - 0_000.txt,0_001.txt,0_002.txt,0_003.txt
All 0 / 400 0_000.txt,0_001.txt,0_002.txt,0_003.txt,1_004.txt,1_005.txt,1_006.txt,1_007.txt,1_008.txt,1_009.txt,1_010.txt,1_011.txt,1_012.txt,1_013.txt,1_014.txt,1_015.txt,1_016.txt,1_017.txt,1_018.txt,1_019.txt,1_020.txt

Test case

Case name Status状態 Exec time実行時間 Memory usageメモリ使用量
0_000.txt AC 1 ms 256 KB
0_001.txt AC 1 ms 256 KB
0_002.txt AC 1 ms 256 KB
0_003.txt AC 1 ms 256 KB
1_004.txt AC 1 ms 256 KB
1_005.txt AC 1 ms 256 KB
1_006.txt WA
1_007.txt AC 1 ms 256 KB
1_008.txt AC 26 ms 3328 KB
1_009.txt AC 23 ms 3328 KB
1_010.txt AC 24 ms 3328 KB
1_011.txt AC 26 ms 3328 KB
1_012.txt AC 25 ms 3328 KB
1_013.txt AC 25 ms 3328 KB
1_014.txt AC 25 ms 3328 KB
1_015.txt AC 25 ms 3328 KB
1_016.txt AC 25 ms 3328 KB
1_017.txt AC 24 ms 3328 KB
1_018.txt WA
1_019.txt AC 23 ms 3328 KB
1_020.txt WA