제출 #1275409

#제출 시각아이디문제언어결과실행 시간메모리
1275409chanhchuong123Deda (COCI17_deda)C++20
140 / 140
345 ms42076 KiB
#include<bits/stdc++.h> using namespace std; const bool multiTest = false; #define task "C" #define fi first #define se second #define MASK(i) (1LL << (i)) #define all(x) (x).begin(), (x).end() #define rall(x) (x).rbegin(), (x).rend() #define BIT(mask, i) ((mask) >> (i) & 1) template<typename T1, typename T2> bool minimize(T1 &a, T2 b) { if (a > b) a = b; else return 0; return 1; } template<typename T1, typename T2> bool maximize(T1 &a, T2 b) { if (a < b) a = b; else return 0; return 1; } const int MAX = 200020; int n, q; int A[MAX]; int B[MAX]; char type[MAX]; set<int> bit[MAX]; vector<int> values; void update(int id, int value) { for (; id <= max(q, n); id += id & -id) bit[id].insert(value); } int get(int id, int value) { int res = MAX; for (; id > 0; id -= id & -id) { auto it = bit[id].lower_bound(value); if (it != bit[id].end()) { minimize(res, *it); } } return res == MAX ? -1 : res; } void process(void) { cin >> n >> q; for (int i = 1; i <= q; ++i) { cin >> type[i] >> A[i] >> B[i]; values.push_back(A[i]); } sort(all(values)); values.resize(unique(all(values)) - values.begin()); for (int i = 1; i <= q; ++i) { A[i] = lower_bound(all(values), A[i]) - values.begin() + 1; if (type[i] == 'M') update(A[i], B[i]); else cout << get(A[i], B[i]) << '\n'; } } int main(void) { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); if (fopen(task".inp", "r")) { freopen(task".inp", "r", stdin); freopen(task".out", "w", stdout); } int nTest = 1; if (multiTest) cin >> nTest; while (nTest--) { process(); } return 0; }

컴파일 시 표준 에러 (stderr) 메시지

deda.cpp: In function 'int main()':
deda.cpp:63:24: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   63 |                 freopen(task".inp", "r",  stdin);
      |                 ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
deda.cpp:64:24: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   64 |                 freopen(task".out", "w", stdout);
      |                 ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...