Submission #7897833


Source Code Expand

/*
				   _ooOoo_
				  o8888888o
				  88" . "88
				  (| -_- |)
				  O\  =  /O
			   ____/`---'\____
			 .'  \\|     |//  `.
			/  \\|||  :  |||//  \
		   /  _||||| -:- |||||-  \
		   |   | \\\  -  /// |   |
		   | \_|  ''\---/''  |   |
		   \  .-\__  `-`  ___/-. /
		 ___`. .'  /--.--\  `. . __
	  ."" '<  `.___\_<|>_/___.'  >'"".
	 | | :  `- \`.;`\ _ /`;.`/ - ` : | |
	 \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
				   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
		fozubaoyou    pass System Test!
		quoted from "https://codeforces.com/contest/472/submission/7996840"
*/
 
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define fin(ans) cout<<(ans)<<endl
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p,q)
#define pb(n) push_back(n)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define Sort(a) sort(a.begin(),a.end())
#define Rort(a) sort(a.rbegin(),a.rend())
#define PI acos(-1)
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);};};
const int MOD = 1000000007;
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;

class WAR_FLY {
public:
	vvi d; //辺の数
	int V; //頂点の数
	
	WAR_FLY(int n) {
		V = n;
		d = vector<vector<int> > (n,vector<int>(n));
		for(int i = 0; i < V; i++) {
			for(int j = 0; j < V; j++) {
				if(i == j) {
					d[i][j] = 0;
				}
				else {
					d[i][j] = INF;
				}
			}
		}
	}

	void warshall_floyd() {
		for(int k = 0; k < V; k++) {
			for(int i = 0; i < V; i++) {
				for(int j = 0; j < V; j++) {
					d[i][j] = min((ll)d[i][j], (ll)d[i][k] + (ll)d[k][j]);
				}
			}
		}
	}

	void add(int from, int to, int cost) {
		d[from][to] = cost;
	}

	bool is_negative_loop() {
		for(int i = 0; i < V; i++) {
			if(d[i][i] < 0) return true;
		}
		return false;
	}

	void show() {
		for(int i = 0; i < V; i++) {
			for(int j = 0; j < V; j++) {
				cout << d[i][j] << " ";
			}
			cout << endl;
		}
	}
};

int main(void){

	int n;
	WAR_FLY wa(n);
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			if(i==j)continue;
			cout<<"? "<<i+1<<" "<<j+1<<endl;
			int c;
			cin>>c;
			wa.add(i,j,c);
		}
	}
	wa.warshall_floyd();
	int ans=0;
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			ans=max(ans,wa.d[i][j]);
		}
	}
	fin(ans);

}

Submission Info

Submission Time
Task D - 高橋くんと木の直径
User xryuseix
Language C++14 (GCC 5.4.1)
Score 0
Code Size 3322 Byte
Status WA
Exec Time 3 ms
Memory 724 KB

Judge Result

Set Name Sample Subtask1 All
Score / Max Score 0 / 0 0 / 20 0 / 80
Status
WA × 1
WA × 22
WA × 42
Set Name Test Cases
Sample subtask0_0.txt
Subtask1 subtask1_0.txt, subtask1_1.txt, subtask1_10.txt, subtask1_11.txt, subtask1_12.txt, subtask1_13.txt, subtask1_14.txt, subtask1_15.txt, subtask1_16.txt, subtask1_17.txt, subtask1_18.txt, subtask1_19.txt, subtask1_2.txt, subtask1_20.txt, subtask1_3.txt, subtask1_4.txt, subtask1_5.txt, subtask1_6.txt, subtask1_7.txt, subtask1_8.txt, subtask1_9.txt, subtask0_0.txt
All subtask0_0.txt, subtask1_0.txt, subtask1_1.txt, subtask1_10.txt, subtask1_11.txt, subtask1_12.txt, subtask1_13.txt, subtask1_14.txt, subtask1_15.txt, subtask1_16.txt, subtask1_17.txt, subtask1_18.txt, subtask1_19.txt, subtask1_2.txt, subtask1_20.txt, subtask1_3.txt, subtask1_4.txt, subtask1_5.txt, subtask1_6.txt, subtask1_7.txt, subtask1_8.txt, subtask1_9.txt, subtask2_0.txt, subtask2_1.txt, subtask2_10.txt, subtask2_11.txt, subtask2_12.txt, subtask2_13.txt, subtask2_14.txt, subtask2_15.txt, subtask2_16.txt, subtask2_17.txt, subtask2_18.txt, subtask2_19.txt, subtask2_2.txt, subtask2_3.txt, subtask2_4.txt, subtask2_5.txt, subtask2_6.txt, subtask2_7.txt, subtask2_8.txt, subtask2_9.txt
Case Name Status Exec Time Memory
subtask0_0.txt WA 3 ms 720 KB
subtask1_0.txt WA 3 ms 720 KB
subtask1_1.txt WA 3 ms 716 KB
subtask1_10.txt WA 3 ms 720 KB
subtask1_11.txt WA 3 ms 720 KB
subtask1_12.txt WA 3 ms 720 KB
subtask1_13.txt WA 3 ms 724 KB
subtask1_14.txt WA 3 ms 720 KB
subtask1_15.txt WA 3 ms 720 KB
subtask1_16.txt WA 3 ms 720 KB
subtask1_17.txt WA 3 ms 720 KB
subtask1_18.txt WA 3 ms 720 KB
subtask1_19.txt WA 3 ms 720 KB
subtask1_2.txt WA 3 ms 716 KB
subtask1_20.txt WA 3 ms 724 KB
subtask1_3.txt WA 3 ms 720 KB
subtask1_4.txt WA 3 ms 720 KB
subtask1_5.txt WA 3 ms 716 KB
subtask1_6.txt WA 3 ms 724 KB
subtask1_7.txt WA 3 ms 716 KB
subtask1_8.txt WA 3 ms 720 KB
subtask1_9.txt WA 3 ms 720 KB
subtask2_0.txt WA 3 ms 720 KB
subtask2_1.txt WA 3 ms 720 KB
subtask2_10.txt WA 3 ms 720 KB
subtask2_11.txt WA 3 ms 720 KB
subtask2_12.txt WA 3 ms 720 KB
subtask2_13.txt WA 3 ms 720 KB
subtask2_14.txt WA 3 ms 720 KB
subtask2_15.txt WA 3 ms 716 KB
subtask2_16.txt WA 3 ms 720 KB
subtask2_17.txt WA 3 ms 720 KB
subtask2_18.txt WA 3 ms 720 KB
subtask2_19.txt WA 3 ms 712 KB
subtask2_2.txt WA 3 ms 724 KB
subtask2_3.txt WA 3 ms 720 KB
subtask2_4.txt WA 3 ms 720 KB
subtask2_5.txt WA 3 ms 720 KB
subtask2_6.txt WA 3 ms 716 KB
subtask2_7.txt WA 3 ms 720 KB
subtask2_8.txt WA 3 ms 720 KB
subtask2_9.txt WA 3 ms 716 KB