# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
644922 |
2022-09-25T14:19:22 Z |
ALI |
Tram (CEOI13_tram) |
C++14 |
|
848 ms |
262144 KB |
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int inf=1e9;
void update(vector<int>& tr,int val, int u, int curL, int curR, int ind){
if(curL==curR&&curL==u){
tr[ind]=val;
return;
}
int mid=(curR+curL)/2;
if(!(u>mid||u<curL)) update(tr,val,u,curL,mid,ind*2+1);
else update(tr,val,u,mid+1,curR,ind*2+2);
tr[ind]=min(tr[ind*2+1],tr[ind*2+2]);
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n,m; cin>>n>>m;
int sze=1;
while(sze<n*2){
sze<<=1;
}
array<vector<int>,3000> tr;
for(vector<int>& v:tr){
v.assign(sze*2-1,inf);
}
vector<pair<int,int>> oper(m);
int x=0;
int y=0;
for(int l=0;l<m;l++){
char ch; cin>>ch;
if(ch=='E'){
int ind=x*2+y;
int maxi=0;
int nx,ny;
for(int i=0;i<2*n;i++){
int x2=i/2;
int y2=i%2;
update(tr[i],(x-x2)*(x-x2)+(y-y2)*(y-y2),ind,0,2*n-1,0);
if(maxi<tr[i][0]){
maxi=tr[i][0];
nx=x2;
ny=y2;
}
}
oper[l]=make_pair(x,y);
cout<<(x+1)<<" "<<(y+1)<<endl;
swap(nx,x);
swap(ny,y);
}else{
int ind; cin>>ind;
int nx;
int ny;
int maxi=0;
ind=oper[ind-1].first*2+oper[ind-1].second;
for(int i=0;i<2*n;i++){
update(tr[i],inf,ind,0,2*n-1,0);
if(maxi<tr[i][0]){
maxi=tr[i][0];
nx=i/2;
ny=i%2;
}
}
swap(nx,x);
swap(ny,y);
}
}
}
Compilation message
tram.cpp: In function 'int main()':
tram.cpp:49:35: warning: 'y' may be used uninitialized in this function [-Wmaybe-uninitialized]
49 | cout<<(x+1)<<" "<<(y+1)<<endl;
| ^
tram.cpp:49:26: warning: 'x' may be used uninitialized in this function [-Wmaybe-uninitialized]
49 | cout<<(x+1)<<" "<<(y+1)<<endl;
| ^~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
13 ms |
12372 KB |
Output is correct |
2 |
Correct |
1 ms |
1108 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
13 ms |
12460 KB |
Output is correct |
2 |
Correct |
2 ms |
1188 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
801 ms |
96748 KB |
Output is correct |
2 |
Correct |
24 ms |
6356 KB |
Output is correct |
3 |
Correct |
806 ms |
96756 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
744 ms |
96628 KB |
Output is correct |
2 |
Correct |
27 ms |
6468 KB |
Output is correct |
3 |
Correct |
848 ms |
96628 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
115 ms |
262144 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
124 ms |
262144 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
130 ms |
262144 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
118 ms |
262144 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |