CODE FESTIVAL 2016 qual C

Submission #1768790

Source codeソースコード

#include<iostream>
#include<cstdio>
#include<vector>
#include<map>
#include<string>
#include<sstream>
#include<cmath>
#include<climits>
#include<algorithm>
#include<bitset>
#include<set>
#include<stack>
#include<queue>
#include<iomanip>
#include<memory.h>
#include<complex>
using namespace std;  
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef tuple<int,int> tii;
#define rep(i,n) for(ll i=0;i<(n);i++)  
#define pb push_back
#define mt make_tuple
#define ALL(a) (a).begin(),(a).end()
#define FST first
#define SEC second  
const int INF = (INT_MAX/2);
const ll LLINF = (LLONG_MAX/2);
const double eps = 1e-8;
const double PI = M_PI;  
#define DEB cerr<<"!"<<endl
#define SHOW(a,b) cerr<<(a)<<" "<<(b)<<endl
#define SHOWARRAY(ar,i,j) REP(a,i)REP(b,j)cerr<<ar[a][b]<<((b==j-1)?((a==i-1)?("\n\n"):("\n")):(" "))
#define DIV int(1e9+7)
inline ll pow(ll x,ll n,ll m){ll r=1;while(n>0){if((n&1)==1)r=r*x%m;x=x*x%m;n>>=1;}return r%m;}
inline ll lcm(ll d1, ll d2){return d1 / __gcd(d1, d2) * d2;}

 /* Coding Space*/
int main(){
  ll n; cin >> n;
  vector<ll> t(n),a(n),x(n);
  rep(i,n) cin >> t[i];
  rep(i,n) cin >> a[i];
  fill(ALL(x),LLINF);
  rep(i,n-1)if(t[i] > t[i+1]){cout<<0<<endl;return 0;}
  rep(i,n-1)if(a[i] < a[i+1]){cout<<0<<endl;return 0;}
  if(t[n-1] != a[0]){cout<<0<<endl;return 0;}
  ll max_h = a[0];
  rep(i,n){
    if(t[i] == max_h){
      if(t[i] == a[i]) break;
      else{cout<<0<<endl;return 0;}
    }
  }
  
  for(int i = 1; i < n; i++) if(t[i-1] != t[i]) x[i] = 1;
  for(int i = n-1; i >= 0; i--){
    x[i] = min(x[i],a[i]);
    x[i] = min(x[i],t[i]);
  }
  for(int i = n-2; i >= 0; i--) if(a[i] != a[i+1]) x[i] = 1;
  x[0] = x[n-1] = 1;
  ll ans = 1;
  //DEB;
  rep(i,n) ans *= x[i],ans %= DIV;
  cout << llabs(ans) << endl;
}

Submission

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

Test case

Set

Set name Score得点 / Max score Cases
Sample - 0_000.txt,0_001.txt,0_002.txt,0_003.txt
All 400 / 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 AC 1 ms 256 KB
1_007.txt AC 1 ms 256 KB
1_008.txt AC 86 ms 2560 KB
1_009.txt AC 71 ms 2560 KB
1_010.txt AC 76 ms 2560 KB
1_011.txt AC 82 ms 2560 KB
1_012.txt AC 77 ms 2560 KB
1_013.txt AC 79 ms 2560 KB
1_014.txt AC 79 ms 2560 KB
1_015.txt AC 80 ms 2560 KB
1_016.txt AC 78 ms 2560 KB
1_017.txt AC 75 ms 2560 KB
1_018.txt AC 71 ms 2560 KB
1_019.txt AC 63 ms 2560 KB
1_020.txt AC 59 ms 2560 KB