# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
79941 |
2018-10-17T13:36:33 Z |
luckyboy |
Deda (COCI17_deda) |
C++14 |
|
193 ms |
13960 KB |
#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
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 time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
512 KB |
Output is correct |
3 |
Correct |
5 ms |
528 KB |
Output is correct |
4 |
Correct |
193 ms |
8064 KB |
Output is correct |
5 |
Correct |
135 ms |
9584 KB |
Output is correct |
6 |
Correct |
150 ms |
12628 KB |
Output is correct |
7 |
Correct |
164 ms |
13960 KB |
Output is correct |