Submission #630227

#TimeUsernameProblemLanguageResultExecution timeMemory
630227Soul234Deda (COCI17_deda)C++14
140 / 140
88 ms7936 KiB
#include<bits/stdc++.h> using namespace std; void DBG() { cerr << "]\n"; } template<class H, class... T> void DBG(H h, T... t) { cerr << h; if(sizeof...(t)) cerr << ", "; DBG(t...); } #ifdef LOCAL #define dbg(...) cerr << "[" << #__VA_ARGS__ << "]: [", DBG(__VA_ARGS__) #else #define dbg(...) 0 #endif // LOCAL #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(e,a) for(auto &e : (a)) #define sz(v) (int)(v).size() #define all(v) (v).begin(),(v).end() #define rall(v) (v).rbegin(),(v).rend() #define pb push_back #define tcT template<class T #define nl "\n" using ll = long long; using vi = vector<int>; using pi = pair<int,int>; using str = string; tcT> using V = vector<T>; tcT> using pqg = priority_queue<T,vector<T>,greater<T>>; void setIO(string NAME = "") { cin.tie(0)->sync_with_stdio(0); if(sz(NAME)) { freopen((NAME + ".inp").c_str(),"r",stdin); freopen((NAME + ".out").c_str(),"w",stdout); } } tcT> bool ckmin(T&a, const T&b) { return b < a ? a=b,1 : 0; } tcT> bool ckmax(T&a, const T&b) { return b > a ? a=b,1 : 0; } const int MOD = 1e9 + 7; struct SegTree { int N; vi mn; int comb(int a, int b) { return min(a,b); } void init(int _N) { N = _N; mn.assign(N*4 + 7, MOD); } void upd(int p, int val, int ind, int L, int R) { if(L > R) return; if(L == R) { mn[ind] = val; return; } int mid = (L + R) >> 1; if(p <= mid) upd(p, val, ind<<1, L, mid); else upd(p, val, ind<<1|1, mid+1, R); mn[ind] = comb(mn[ind<<1], mn[ind<<1|1]); } void upd(int p, int val) { upd(p, val, 1, 1, N); } int query(int pos, int val, int ind, int L, int R) { if(pos > R || L > R || mn[ind] > val) return -1; if(L == R) return L; int mid = (L + R) >> 1; int res = query(pos, val, ind<<1, L, mid); if(~res) return res; return query(pos, val, ind<<1|1, mid+1, R); } int query(int pos, int val) { return query(pos, val, 1, 1, N); } }; int N, Q; SegTree st; void solve() { cin >> N >> Q; st.init(N); while(Q-- > 0) { char t; cin >> t; if(t == 'M') { int nval, pos; cin >> nval >> pos; st.upd(pos, nval); } else { int Y, B; cin >> Y >> B; cout << st.query(B, Y) << nl; } } } int main() { setIO(); int t=1; //cin>>t; while(t-->0) { solve(); } return 0; }

Compilation message (stderr)

deda.cpp: In function 'void setIO(std::string)':
deda.cpp:37:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   37 |         freopen((NAME + ".inp").c_str(),"r",stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
deda.cpp:38:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   38 |         freopen((NAME + ".out").c_str(),"w",stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...