Submission #412909

# Submission time Handle Problem Language Result Execution time Memory
412909 2021-05-27T19:05:57 Z JerryLiu06 Deda (COCI17_deda) C++17
20 / 140
129 ms 4600 KB
#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using db = long double;
using str = string;

using pi = pair<int, int>;
using pl = pair<ll, ll>;
using pd = pair<db, db>;

using vi = vector<int>;
using vb = vector<bool>;
using vl = vector<ll>;
using vd = vector<db>;
using vs = vector<str>;
using vpi = vector<pi>;
using vpl = vector<pl>;
using vpd = vector<pd>;

#define mp make_pair
#define f first
#define s second

#define sz(x) (int)(x).size()
#define bg(x) begin(x)
#define all(x) bg(x), end(x)
#define sor(x) sort(all(x))
#define ft front()
#define bk back()
#define pb push_back
#define pf push_front

#define lb lower_bound
#define ub upper_bound

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define F0R(i, a) FOR(i, 0, a)
#define ROF(i, a, b) for (int i = (b) - 1; i >= (a); i--)
#define R0F(i, a) ROF(i, 0, a)
#define EACH(a, x) for (auto& a : x)

const int MOD = 1e9 + 7;
const int MX = 2e5 + 10;
const ll INF = 1e18;

int N, Q; int tree[4 * MX];

void update(int x, int l, int r, int pos, int val) { int mid = (l + r) / 2;
    if (l > pos || r < pos) return ; if (l == r) { tree[x] = val; return ; }

    update(2 * x, l, mid, pos, val); update(2 * x + 1, mid + 1, r, pos, val);

    tree[x] = min(tree[2 * x], tree[2 * x + 1]);
}
int first(int x, int l, int r, int tl, int val) { int mid = (l + r) / 2;
    if (l == r) { if (tree[x] <= val) return l; return -1; }
    
    if (tl <= mid && tree[2 * x] <= val) return first(2 * x, l, mid, tl, val);
    
    if (tl <= r && tree[2 * x + 1] <= val) return first(2 * x + 1, mid + 1, r, tl, val); return -1;
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);

    cin >> N >> Q; FOR(i, 1, 4 * MX) tree[i] = MOD;
    
    F0R(i, Q) {
        char C; int A, B; cin >> C >> A >> B;

        if (C == 'M') update(1, 1, N, B, A); else cout << first(1, 1, N, B, A) << "\n";
    }
}

Compilation message

deda.cpp: In function 'void update(int, int, int, int, int)':
deda.cpp:51:5: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   51 |     if (l > pos || r < pos) return ; if (l == r) { tree[x] = val; return ; }
      |     ^~
deda.cpp:51:38: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   51 |     if (l > pos || r < pos) return ; if (l == r) { tree[x] = val; return ; }
      |                                      ^~
deda.cpp: In function 'int first(int, int, int, int, int)':
deda.cpp:62:5: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   62 |     if (tl <= r && tree[2 * x + 1] <= val) return first(2 * x + 1, mid + 1, r, tl, val); return -1;
      |     ^~
deda.cpp:62:90: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   62 |     if (tl <= r && tree[2 * x + 1] <= val) return first(2 * x + 1, mid + 1, r, tl, val); return -1;
      |                                                                                          ^~~~~~
# Verdict Execution time Memory Grader output
1 Correct 3 ms 3404 KB Output is correct
2 Incorrect 3 ms 3436 KB Output isn't correct
3 Incorrect 5 ms 3404 KB Output isn't correct
4 Incorrect 88 ms 4600 KB Output isn't correct
5 Incorrect 101 ms 4032 KB Output isn't correct
6 Incorrect 129 ms 4168 KB Output isn't correct
7 Incorrect 103 ms 4292 KB Output isn't correct