Submission #1965149
Source Code Expand
#include<iostream> #include<string> #include<vector> #include<utility> #include<queue> #include<algorithm> #include<cmath> #include<cstdio> #include<cstring> #define INF 2147483647 #define llINF 9223372036854775807 #define pb push_back #define mp make_pair #define F first #define S second #define ll long long using namespace std; int main(){ int n;cin>>n; vector<ll>t(n); vector<ll>a(n); for(int i=0;i<n;i++) cin>>t[i]; for(int i=0;i<n;i++) cin>>a[i]; //reverse(a.begin(),a.end()); bool flag[n]={}; flag[0]=true; flag[n-1]=true; for(int i=1;i<n;i++){ if(t[i]!=t[i-1])flag[i]=true; } for(int i=n-2;i>=0;i--){ if(a[i]!=a[i+1])flag[i]=true; } const ll MOD=1000000007; ll ans=1; ll nnn=0; for(int i=0;i<n;i++){ int cnt=0; while((i!=n)&&(!flag[i])){ cnt++; i++; } if(cnt>0){ ll ans2=1; ll num=min(a[i-1],t[i-1]); for(int j=0;j<cnt;j++){ ans=(ans*num)%MOD; } } } bool flag2=false; for(int i=0;i<n;i++){ if(a[i]==t[n-1]&&t[i]==t[n-1]){ flag2=true; break; } } if((t[n-1]!=a[0])||flag2){ cout<<0<<endl; }else if(n==1&&a[0]==t[0]) cout<<1<<endl; else cout<<ans<<endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | C - Two Alpinists |
User | shi |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 1297 Byte |
Status | WA |
Exec Time | 92 ms |
Memory | 1920 KB |
Judge Result
Set Name | Sample | All | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 400 | ||||||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | 0_000.txt, 0_001.txt, 0_002.txt, 0_003.txt |
All | 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 |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
0_000.txt | WA | 1 ms | 256 KB |
0_001.txt | AC | 1 ms | 256 KB |
0_002.txt | WA | 1 ms | 256 KB |
0_003.txt | WA | 1 ms | 256 KB |
1_004.txt | AC | 1 ms | 256 KB |
1_005.txt | WA | 1 ms | 256 KB |
1_006.txt | WA | 1 ms | 256 KB |
1_007.txt | WA | 1 ms | 256 KB |
1_008.txt | WA | 87 ms | 1920 KB |
1_009.txt | WA | 71 ms | 1920 KB |
1_010.txt | WA | 76 ms | 1920 KB |
1_011.txt | WA | 80 ms | 1920 KB |
1_012.txt | WA | 78 ms | 1920 KB |
1_013.txt | WA | 80 ms | 1920 KB |
1_014.txt | WA | 81 ms | 1920 KB |
1_015.txt | WA | 92 ms | 1920 KB |
1_016.txt | WA | 79 ms | 1920 KB |
1_017.txt | WA | 75 ms | 1920 KB |
1_018.txt | WA | 73 ms | 1920 KB |
1_019.txt | WA | 63 ms | 1920 KB |
1_020.txt | WA | 60 ms | 1920 KB |