Submission #1455371


Source Code Expand

#include <bits/stdc++.h>

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplece_back
#define mp make_pair
#define i_i pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< i_i >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; scanf("%lld", &x);
#define int2(x, y) int x, y; scanf("%lld %lld", &x, &y);
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second

//int dxy[5] = {0, 1, 0, -1, 0};
// assign avl ncm dijkstra geo2 kruskal graph uf lca BIT
// matrix dinic

signed main()
{
    Int(n);
    vi l(n), r(n);
    rep(i, n) {
        cin >> l[i];
    }
    rep(i, n) {
        cin >> r[i];
    }

    vb rcheck(n, false), lcheck(n, false);
    rcheck[n-1] = true; lcheck[0] = true;
    Rep(i, n) {
        if (l[i] != l[i-1]) {
            lcheck[i] = true;
        }
    }

    for (int i = n-1; i > 0; i--) {
        if (r[i] != r[i-1]) {
            rcheck[i-1] = true;
        }
    }

    rep(i, n) {
        if (rcheck[i] && lcheck[i] && 
                r[i] != l[i]) {
            std::cout << 0 << std::endl;
            return 0;
        }
        if (rcheck[i] && !lcheck[i] && 
                r[i] > l[i]) {
            std::cout << 0 << std::endl;
            return 0;
        }
        if (!rcheck[i] && lcheck[i] && 
                r[i] < l[i]) {
            std::cout << 0 << std::endl;
            return 0;
        }
    }
    /*
    rep(i, n) {
        cout << lcheck[i] << " ";
    }
    cout << endl;
    rep(i, n) {
        cout << rcheck[i] << " ";
    }
    cout << endl;
    */


    int ans = 1;
    rep(i, n) {
        if (!rcheck[i] && !lcheck[i]) {
            ans *= min(r[i], l[i]);
            ans %= MOD;
        }
    }
    std::cout << ans << std::endl;

    return 0;
}



Submission Info

Submission Time
Task C - Two Alpinists
User Ti11192916
Language C++14 (GCC 5.4.1)
Score 400
Code Size 2237 Byte
Status AC
Exec Time 86 ms
Memory 1792 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:22:40: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
 #define Int(x) int x; scanf("%lld", &x);
                                        ^
./Main.cpp:37:5: note: in expansion of macro ‘Int’
     Int(n);
     ^

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 400 / 400
Status
AC × 4
AC × 21
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 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 1792 KB
1_009.txt AC 71 ms 1792 KB
1_010.txt AC 76 ms 1792 KB
1_011.txt AC 80 ms 1792 KB
1_012.txt AC 77 ms 1792 KB
1_013.txt AC 79 ms 1792 KB
1_014.txt AC 79 ms 1792 KB
1_015.txt AC 80 ms 1792 KB
1_016.txt AC 77 ms 1792 KB
1_017.txt AC 74 ms 1792 KB
1_018.txt AC 73 ms 1792 KB
1_019.txt AC 63 ms 1792 KB
1_020.txt AC 59 ms 1792 KB