Submission #730493

# Submission time Handle Problem Language Result Execution time Memory
730493 2023-04-26T03:38:53 Z abcvuitunggio None (JOI16_dungeon2) C++17
0 / 100
1 ms 724 KB
#include "dungeon2.h"
#include <bits/stdc++.h>
using namespace std;
int g[101][101],matrix[101][101],mat[101][101],p[101],par[101],id=1,ch[101];
vector <pair <int, int>> ve;
int findnode(int u, int i){
    int j=LastRoad();
    Move(j,Color());
    memset(ch,0,sizeof(ch));
    int cur=u;
    for (int i=ve.size()-1;i>=0;i--){
        Move(p[cur],Color());
        cur=par[cur];
        if (j<=NumberOfRoads()){
            Move(j,Color());
            ch[cur]=(Color()==2);
            Move(LastRoad(),Color());
        }
    }
    for (auto [i,j]:ve)
        Move(j,Color());
    Move(p[u],1);
    for (int i=ve.size()-1;i>=0;i--){
        if (j<=NumberOfRoads()){
            Move(j,Color());
            if (Color()==1&&ch[ve[i].first])
                return ve[i].first;
            Move(LastRoad(),Color());
        }
        Move(p[ve[i].first],Color());
    }
}
void dfs(int u){
    p[u]=LastRoad();
    int cnt=NumberOfRoads();
    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;
            }
            int v=findnode(u,i);
            g[u][v]=g[v][u]=1;
        }
    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++)
            g[i][j]=(g[i][j]?1:1e9);
    for (int i=1;i<=n;i++)
        g[i][i]=0;
    for (int k=1;k<=n;k++)
        for (int i=1;i<=n;i++)
            for (int j=1;j<=n;j++)
                g[i][j]=min(g[i][j],g[i][k]+g[k][j]);
	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+=(g[j][k]==i);
        Answer(i,cnt);
	}
}

Compilation message

dungeon2.cpp: In function 'void Inspect(int)':
dungeon2.cpp:67:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   67 |     for (int k=1;k<=n;k++)
      |     ^~~
dungeon2.cpp:71:2: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   71 |  int i;
      |  ^~~
dungeon2.cpp: In function 'int findnode(int, int)':
dungeon2.cpp:32:1: warning: control reaches end of non-void function [-Wreturn-type]
   32 | }
      | ^
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Incorrect 1 ms 352 KB Wrong Answer [4]
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 312 KB Wrong Answer [4]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 724 KB Wrong Answer [5]
2 Halted 0 ms 0 KB -