1.思路很难想,但代码一看一下就明白了,就是模拟时间,map存起来遍历也不受10*6影响
2.每次先统计点对应的直线,再动这个点,map一遍历实时更新ma统计max,AC!!!!
https://www.luogu.com.cn/problem/P8695
#include<bits/stdc++.h>
using namespace std;
#define N 100011
typedef long long ll;
typedef pair<ll,int> pii;
int n,q;
vector<int> mp[N];
int fa[N][25];
int d[N];
struct node
{int x,y,tx,ty;} ;
vector<node> a;
int ma;
int main() {ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);int t=500;cin>>n;for(int i=0;i<n;i++){int e,b,c;char ch;cin>>e>>b>>c;cin>>ch;node w;if(ch=='U'){w.ty=c;w.tx=0;}elseif(ch=='D'){w.ty=-1*c;w.tx=0;}elseif(ch=='L'){w.tx=-1*c;w.ty=0;}else{w.tx=c;w.ty=0;}w.x=e;w.y=b;a.push_back(w);}while(t--){map<int,int> x,y;for(int i=0;i<a.size();i++){x[a[i].x]++;y[a[i].y]++;a[i].x+=a[i].tx;a[i].y+=a[i].ty;}for(auto w:x){ma=max(ma,w.second);}for(auto w:y){ma=max(ma,w.second);}}cout<<ma;return 0;
}