Submission #730520

#TimeUsernameProblemLanguageResultExecution timeMemory
730520abcvuitunggioDungeon 2 (JOI16_dungeon2)C++17
80 / 100
21 ms1508 KiB
#include "dungeon2.h" #include <bits/stdc++.h> using namespace std; int g[201][201],d[201][201],matrix[201][201],mat[201][201],p[201],par[201],id=1; vector <pair <int, int>> ve; vector <int> ke[201]; queue <int> q; void findnode(int u, vector <int> V){ if (V.empty()) return; for (int i:V){ Move(i,1); Move(LastRoad(),1); } int cur=u,cnt=V.size(),i; for (i=ve.size()-1;i>=0;i--){ Move(p[cur],2); cur=par[cur]; if (Color()==1){ g[u][cur]=g[cur][u]=1; cnt--; if (!cnt) break; } } for (;i<ve.size();i++) Move(ve[i].second,2); } 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){ ve.push_back({u,i}); id++; g[u][id]=g[id][u]=1; par[id]=u; dfs(id); ve.pop_back(); continue; } V.push_back(i); Move(LastRoad(),2); } findnode(u,V); if (u!=1) Move(p[u],3); } void Inspect(int R) { dfs(1); int n=id; for (int i=1;i<=n;i++) for (int j=1;j<=n;j++){ if (g[i][j]) ke[i].push_back(j); g[i][j]=(g[i][j]?1:1e9); } 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); } } } int i; for (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 findnode(int, std::vector<int>)':
dungeon2.cpp:26:12: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |     for (;i<ve.size();i++)
      |           ~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...