제출 #483548

#제출 시각아이디문제언어결과실행 시간메모리
483548enviflyTracks in the Snow (BOI13_tracks)C++17
0 / 100
2106 ms614976 KiB
#include <bits/stdc++.h> #ifndef LOCAL #define debug(...) 0 #else #include "C:\programmingfunnyxd\debug.cpp" #endif using namespace std; #define int long long int n,m; char grid[4000][4000]; bool fvisited[4000][4000], svisited[4000][4000]; const int dx[4] = {1,-1,0,0}; const int dy[4] = {0,0,-1,1}; char first, second; void firstfill(int r, int c){ if(r < 0 || r >= n || c < 0 || c >= m)return; if(fvisited[r][c] || grid[r][c] != first)return; fvisited[r][c] = true; for(int i = 0; i < n; i++){ firstfill(dx[i]+r, dy[i]+c); } } void secondfill(int r, int c){ if(r < 0 || r >= n || c < 0 || c >= m)return; if(svisited[r][c])return; if(!fvisited[r][c] && grid[r][c] != second)return; svisited[r][c] = true; for(int i = 0; i < n; i++){ secondfill(dx[i]+r, dy[i]+c); } } main(){ ios::sync_with_stdio(0); cin.tie(0); cin>>n>>m; for(int i = 0; i < n; i++){ for(int j = 0; j < m; j++){ cin>>grid[i][j]; } } first = grid[0][0]; int ans = 0; for(int i = 0; i < n; i++){ for(int j = 0; j < m; j++){ if(grid[i][j] == first && !fvisited[i][j]){ ans++; firstfill(i,j); } } } second = (first == 'F' ? 'R' : 'F'); for(int i = 0; i < n; i++){ for(int j = 0; j < m; j++){ if(grid[i][j] == second and !svisited[i][j]){ ans++; secondfill(i,j); } } } cout<<ans; }

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

tracks.cpp:37:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   37 | main(){
      | ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...