Submission #79941

#TimeUsernameProblemLanguageResultExecution timeMemory
79941luckyboyDeda (COCI17_deda)C++14
140 / 140
193 ms13960 KiB
#include <bits/stdc++.h> #define FOR(i, a, b) for (int i = (a); i <= (b); ++i) #define FORD(i, a, b) for (int i = (a); i >= (b); --i) #define pb push_back #define mp make_pair #define F first #define S second #define maxc 1000000007 #define maxn 200005 #define maxm 500005 #define pii pair <int,int> #define Task "Deda" using namespace std; int n,q,t[maxn << 2],x,y; char c; void Update(int l,int r,int id,int x,int val) { t[id] = min(t[id],val); if (l == r) return; int mid = (l+r) >> 1; if (mid >= x) Update(l,mid,2*id,x,val); else Update(mid+1,r,2*id+1,x,val); } int Find(int l,int r,int id,int x,int val) { if (r < x) return 0; if (l == r) return (t[id] <= val ? l : 0); if (x <= l && t[id] > val) return 0; int mid = (l+r) >> 1; int temp = Find(l,mid,2*id,x,val); if (temp) return temp; return Find(mid+1,r,2*id+1,x,val); } int main() { //freopen(Task".inp", "r",stdin); //freopen(Task".out", "w",stdout); scanf("%d%d",&n,&q); FOR(i,1,n << 2) t[i] = maxc; while (q--) { scanf("%c%c%d%d",&c,&c,&x,&y); if (c == 'M') Update(1,n,1,y,x); else { int ans = Find(1,n,1,y,x); if (!ans) ans = -1; printf("%d\n",ans); } } return 0; }

Compilation message (stderr)

deda.cpp: In function 'int main()':
deda.cpp:38:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d",&n,&q);
     ~~~~~^~~~~~~~~~~~~~
deda.cpp:42:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%c%c%d%d",&c,&c,&x,&y);
         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...