Submission #730598

#TimeUsernameProblemLanguageResultExecution timeMemory
730598abcvuitunggioDungeon 2 (JOI16_dungeon2)C++17
100 / 100
30 ms1364 KiB
#include "dungeon2.h" #include <bits/stdc++.h> using namespace std; int d[201][201],matrix[201][201],mat[201][201],p[201],par[201],id=1,pw=1; vector <int> ke[201],e[201],ve[201],ve2[201]; queue <int> q; void dfs(int u){ p[u]=LastRoad(); int cnt=NumberOfRoads(); vector <int> V; for (int i=1;i<=cnt;i++) if (i!=p[u]){ Move(i,2); if (Color()==3){ Move(LastRoad(),3); continue; } if (Color()==1){ e[u].push_back(i); id++; ke[u].push_back(id); par[id]=u; dfs(id); continue; } ve[u].push_back(i); ve2[u].push_back(0); Move(LastRoad(),2); } if (u!=1) Move(p[u],3); } void dfs2(int u){ for (int i=0;i<ve[u].size();i++){ int v=ve[u][i]; Move(v,Color()); ve2[u][i]+=(Color()-1)*pw; Move(LastRoad(),Color()); } for (int i=0;i<ke[u].size();i++){ Move(e[u][i],u/pw%3+1); dfs2(ke[u][i]); } if (u!=1) Move(p[u],3); } void Inspect(int R){ dfs(1); for (int i=0;i<5;i++){ dfs2(1); pw*=3; } int n=id; for (int i=1;i<=n;i++) for (int j:ve2[i]) ke[i].push_back(j); for (int i=1;i<=n;i++) for (int j:ke[i]) ke[j].push_back(i); memset(d,-1,sizeof(d)); int cnt=0; for (int i=1;i<=n;i++){ cnt+=ke[i].size(); q.push(i); d[i][i]=0; while (!q.empty()){ int u=q.front(); q.pop(); for (int v:ke[u]) if (d[i][v]==-1){ d[i][v]=d[i][u]+1; q.push(v); } } } for (int i=1;i<=R;i++){ int cnt=0; for (int j=1;j<=n;j++) for (int k=j+1;k<=n;k++) cnt+=(d[j][k]==i); Answer(i,cnt); } }

Compilation message (stderr)

dungeon2.cpp: In function 'void dfs2(int)':
dungeon2.cpp:34:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |     for (int i=0;i<ve[u].size();i++){
      |                  ~^~~~~~~~~~~~~
dungeon2.cpp:40:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   40 |     for (int i=0;i<ke[u].size();i++){
      |                  ~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...