답안 #105475

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
105475 2019-04-12T14:46:33 Z reality Bitaro, who Leaps through Time (JOI19_timeleap) C++17
0 / 100
3000 ms 8412 KB
#include "bits/stdc++.h"
using namespace std;
#define fi first
#define se second
#define ll long long
#define dbg(v) cerr<<#v<<" = "<<v<<'\n'
#define vi vector<int>
#define vl vector <ll>
#define pii pair<int,int>
#define vii vector < pii >
#define mp make_pair
#define db long double
#define pb push_back
#define all(s) s.begin(),s.end()
template < class P , class Q > ostream& operator<<(ostream& stream, pair < P , Q > v){ stream << "(" << v.fi << ',' << v.se << ")"; return stream;}
template < class T > ostream& operator<<(ostream& stream, const vector<T> v){ stream << "[ "; for (int i=0; i<(int)v.size(); i++) stream << v[i] << " "; stream << "]"; return stream;}
template < class T > T smin(T &a,T b) {if (a > b) a = b;return a;}
template < class T > T smax(T &a,T b) {if (a < b) a = b;return a;}
const int N = 1e6 + 5;
int l[N],r[N];
int main(void) {
    int n,q;
    cin.tie(0);
    ios_base :: sync_with_stdio(0);
    cin>>n>>q;
    for (int i = 1;i < n;++i)
        cin>>l[i]>>r[i];
    while (q --) {
        int tp;
        cin>>tp;
        if (tp == 1) {
            int pos,lf,rg;
            cin>>pos>>lf>>rg;
            l[pos] = lf;
            r[pos] = rg;
        } else {
            int a,b,c,d;
            cin>>a>>b>>c>>d;
            ll ans = 0;
            if (a > c) {
                for (int i = a;i > c;--i) {
                    smax(b,l[i - 1]);
                    ans += max(0,b - (r[i - 1] - 1));
                    smin(b,r[i - 1] - 1);
                    ++b;
                }
                ans += max(0,b - d);
            } else {
                for (int i = a;i < c;++i) {
                    smax(b,l[i - 1]);
                    ans += max(0,b - (r[i] - 1));
                    smin(b,r[i] - 1);
                    ++b;
                }
                ans += max(0,b - d);
            }
            cout << ans << '\n';
        }
    }
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3081 ms 8412 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -