제출 #1342673

#제출 시각아이디문제언어결과실행 시간메모리
1342673weedywelon컴퓨터 네트워크 (BOI14_network)C++20
0 / 100
58 ms4304 KiB
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iostream>
#include <iomanip>
#include <limits.h>
#include <set>
#include <string>
#include <queue>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <deque>
#include <map>
#include <chrono>
#include <random>
#include <bitset>
#include <tuple>
#include "network.h"
#define SZ(x) int(x.size())
#define FR(i,a,b) for(int i=(a);i<(b);++i)
#define FOR(i,n) FR(i,0,n)
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define A first
#define B second
#define mp(a,b) make_pair(a,b)
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
typedef unsigned __int128 U128;
typedef __int128 I128;
typedef std::pair<int,int> PII;
typedef std::pair<LL,LL> PLL;
using namespace std;

//n^2 get all edges 
//run bfs

//so u know all the dists from a 
//let dist from a to b be d
//categorise by distance to a
//2n: get all nodes that are along a shortest path
//fix the one u want to travel to
//for each x at distance, check whether prev is on a shortest path from a to x
//build the path

//ok maybe we dont need to find out whats on shortest path
//categorise by distance from b? n calls
//start from a
//if traverse an edge, dist-- -> youve moved along a shortest path n calls
//is this tuff

vector<int> d[1003]; //distance from b
void findRoute (int N, int a, int b){
	int n=N;
	vector<PII> v(n+1);
	int dist=ping(a,b);
	FR(i,1,n+1){
		if (i==a || i==b) continue;
		int tmp=ping(i,b)+1;
		d[tmp].push_back(i);
	}
	
	vector<int> path;
	int cur=a;
	for (int i=dist-1; i>0; i--){
		for (int x:d[i]) if (ping(x,cur)==0){
			path.push_back(x);
			cur=x;
			break;
		}
	}
	path.push_back(b);
	for (int u:path) travelTo(u);
	return;
}

컴파일 시 표준 에러 (stderr) 메시지

grader.c: In function 'int main()':
grader.c:48:11: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   48 |     scanf ("%d%d%d%d", &N, &a, &b, &M);
      |     ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
grader.c:51:18: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   51 |             scanf("%d", &distance[u][v]);
      |             ~~~~~^~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...