제출 #1239723

#제출 시각아이디문제언어결과실행 시간메모리
1239723Noname_1900Tracks in the Snow (BOI13_tracks)C++20
47.50 / 100
2119 ms1079028 KiB
#include<bits/stdc++.h> using namespace std; const int NMAX = 4000; const int INFINI = 1000000; char tab[NMAX][NMAX]; int nbAVoir; int nbL, nbC; int dir[4][2] = {{0, 1}, {0, -1}, {1, 0}, {-1, 0}}; int dejaVu[NMAX][NMAX]; void parcourir(int l, int c, char typeActu, int iDejaVu) { if((l < 0) || (c < 0) || (l >= nbL) || (c >= nbC)) return; if(dejaVu[l][c] == iDejaVu) return; dejaVu[l][c] = iDejaVu; // cout << l << " " << c << "\n"; if((tab[l][c] == typeActu)) { nbAVoir--; tab[l][c] = 'T'; } else if(tab[l][c] != 'T') return; for(int iD = 0; iD < 4; iD++) { parcourir(l+dir[iD][0], c+dir[iD][1], typeActu, iDejaVu); } } int main() { ios::sync_with_stdio(false); cin.tie(0); cin >> nbL >> nbC; nbAVoir = 0; for(int l = 0; l < nbL; l++) { for(int c = 0; c < nbC; c++) { cin >> tab[l][c]; if(tab[l][c] != '.') nbAVoir++; } } char dep = tab[0][0]; int nbTypes = 0; while(nbAVoir) { nbTypes++; parcourir(0, 0, dep, nbTypes); if(dep == 'F') dep = 'R'; else dep = 'F'; } cout << nbTypes; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...