제출 #1318580

#제출 시각아이디문제언어결과실행 시간메모리
1318580mibngorTracks in the Snow (BOI13_tracks)C++20
56.67 / 100
619 ms293076 KiB
#include<bits/stdc++.h> #define ll long long #define pb push_back #define pp pop_back #define emp emplace_back #define ins insert #define fi first #define se second #define sz(x) x.size() #define fop if(fopen("hello.inp","r")){freopen("hello.inp","r",stdin);freopen("hello.out","w",stdout);} #define ls ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); using namespace std; mt19937_64 rd(chrono::steady_clock::now().time_since_epoch().count()); ll Rd(ll l,ll r) { return uniform_int_distribution<int>(l,r)(rd); } const int N = 4e3 + 7; int h,w,x[4] = {0,1,0,-1},y[4] = {1,0,-1,0},rs = 1; bool vst[N][N]; char a[N][N]; void bfs(ll nx,ll ny) { deque<pair<int,int>> dq; dq.push_back({nx,ny}); char cur = a[nx][ny]; while(!dq.empty()) { auto u = dq.front(); dq.pop_front(); if(vst[u.fi][u.se]) continue; vst[u.fi][u.se] = 1; if(cur != a[u.fi][u.se]) { rs++; cur = a[u.fi][u.se]; } for(int i = 0; i < 4; i++) { pair<int,int> v; v.fi = u.fi + x[i]; v.se = u.se + y[i]; if(v.fi < 1 || v.fi > h) continue; if(v.se < 1 || v.se > h) continue; if(a[v.fi][v.se] == '.') continue; if(a[v.fi][v.se] != cur) dq.push_back(v); else dq.push_front(v); } } } main() { fop; ls; cin >> h >> w; for(int i = 1; i <= h; i++) for(int j = 1; j <= w; j++) cin >> a[i][j]; bfs(1,1); cout << rs; }

컴파일 시 표준 에러 (stderr) 메시지

tracks.cpp:56:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   56 | main()
      | ^~~~
tracks.cpp: In function 'int main()':
tracks.cpp:10:47: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   10 | #define fop if(fopen("hello.inp","r")){freopen("hello.inp","r",stdin);freopen("hello.out","w",stdout);}
      |                                        ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
tracks.cpp:58:5: note: in expansion of macro 'fop'
   58 |     fop;
      |     ^~~
tracks.cpp:10:78: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   10 | #define fop if(fopen("hello.inp","r")){freopen("hello.inp","r",stdin);freopen("hello.out","w",stdout);}
      |                                                                       ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
tracks.cpp:58:5: note: in expansion of macro 'fop'
   58 |     fop;
      |     ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...