Submission #1134895

#TimeUsernameProblemLanguageResultExecution timeMemory
11348958pete8Toy (CEOI24_toy)C++20
100 / 100
109 ms44616 KiB
#include<iostream> #include<stack> #include<map> #include<vector> #include<string> #include<cassert> #include<unordered_map> #include <queue> #include <cstdint> #include<cstring> #include<limits.h> #include<cmath> #include<set> #include<algorithm> #include <iomanip> #include<numeric> #include<bitset> using namespace std; #define ll long long #define f first #define s second #define pii pair<int,int> #define ppii pair<int,pii> #define vi vector<int> #define pb push_back #define all(x) x.begin(),x.end() #define rall(x) x.rbegin(),x.rend() #define F(n) for(int i=0;i<n;i++) #define lb lower_bound #define ub upper_bound #define fastio ios::sync_with_stdio(false);cin.tie(NULL); #pragma GCC optimize ("03,unroll-lopps") #define int long long using namespace std; const int mod=1e9+7,mxn=2e5+5,inf=1e18,minf=-1e18,lg=30; //#undef int int n,k,m,w,h,l; void setIO(string name){ ios_base::sync_with_stdio(0); cin.tie(0); freopen((name+".in").c_str(),"r",stdin); freopen((name+".out").c_str(),"w",stdout); } int vis[2002][2002]; char grid[2002][2002]; vector<int>X[2002],Y[2002]; int32_t main(){ fastio cin>>w>>h>>k>>l; int x1,y1,x2,y2;cin>>x1>>y1>>x2>>y2; for(int j=0;j<h;j++)for(int i=0;i<w;i++){ cin>>grid[i][j]; if(grid[i][j]=='X'){ X[i].pb(j); Y[j].pb(i); } } for(int i=0;i<w;i++){ X[i].pb(-1),X[i].pb(h); sort(all(X[i])); X[i].erase(unique(all(X[i])),X[i].end()); } for(int i=0;i<h;i++){ Y[i].pb(-1),Y[i].pb(w); sort(all(Y[i])); Y[i].erase(unique(all(Y[i])),Y[i].end()); } //x , y queue<pii>q; q.push({x2,y1}); while(!q.empty()){ int cx=q.front().f,cy=q.front().s; q.pop(); if(vis[cx][cy])continue; vis[cx][cy]=1; //x+1 right //x-1 left //y+1 down //y-1 up for(int add=-1;add<=1;add+=2){ pii bound; if(cx+add<w&&cx+add>=0&&grid[cx+add][cy]!='X'&&!vis[cx+add][cy]){ auto it=lb(all(X[cx]),cy); bound={(*prev(it)),(*it)}; it=lb(all(X[cx+add]),cy); bound={max(bound.f,(*prev(it))),min(bound.s,(*it))}; if(bound.s-bound.f-1>=l)q.push({cx+add,cy}); } if(cy+add<h&&cy+add>=0&&grid[cx][cy+add]!='X'&&!vis[cx][cy+add]){ auto it=lb(all(Y[cy]),cx); bound={(*prev(it)),(*it)}; it=lb(all(Y[cy+add]),cx); bound={max(bound.f,(*prev(it))),min(bound.s,(*it))}; if(bound.s-bound.f-1>=k)q.push({cx,cy+add}); } } } for(int i=0;i<w;i++)for(int j=0;j<h;j++)if(grid[i][j]=='*'){ if(vis[i][j])cout<<"YES\n"; else cout<<"NO\n"; return 0; } } /* */

Compilation message (stderr)

Main.cpp:32:40: warning: bad option '-funroll-lopps' to pragma 'optimize' [-Wpragmas]
   32 | #pragma GCC optimize ("03,unroll-lopps")
      |                                        ^
Main.cpp:38:23: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
   38 | void setIO(string name){
      |                       ^
Main.cpp:46:14: warning: bad option '-funroll-lopps' to attribute 'optimize' [-Wattributes]
   46 | int32_t main(){
      |              ^
Main.cpp: In function 'void setIO(std::string)':
Main.cpp:40:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   40 |         freopen((name+".in").c_str(),"r",stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:41:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   41 |         freopen((name+".out").c_str(),"w",stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...