Submission #931370

#TimeUTC-0UsernameProblemLanguageResultExecution timeMemory
9313702024-02-21 16:39:08sofija6Tracks in the Snow (BOI13_tracks)C++14
91.25 / 100
2051 ms1048576 KiB
#include <bits/stdc++.h>
#define ll int
#define MAXN 4010
using namespace std;
char c[MAXN][MAXN];
ll a[MAXN][MAXN],cur=1,dist[MAXN*MAXN];
bool V[MAXN][MAXN];
set<pair<ll,ll> > s;
vector<ll> G[MAXN*MAXN];
void DFS(ll i,ll j)
{
a[i][j]=cur;
V[i][j]=true;
for (ll x=-1;x<2;x++)
{
for (ll y=-1;y<2;y++)
{
if (abs(x)+abs(y)==1)
{
if (c[i+x][j+y]==c[i][j] && !V[i+x][j+y])
DFS(i+x,j+y);
else if (c[i+x][j+y]!=c[i][j] && V[i+x][j+y] && !s.count({a[i+x][j+y],cur}))
{
G[a[i+x][j+y]].push_back(cur);
G[cur].push_back(a[i+x][j+y]);
s.insert({a[i+x][j+y],cur});
}
}
}
}
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...