Submission #48268533


Source Code Expand

// LUOGU_RID: 138672937
#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;

#define rep(i,l,r) for(int i(l);i<=(r);++i)
#define per(i,r,l) for(int i(r);i>=(l);--i)
#define eb emplace_back
#define File(filename) freopen(filename ".in","r",stdin),freopen(filename ".out","w",stdout)

#ifdef EXODUS
	#define Debug(...) fprintf(stderr,__VA_ARGS__)
#else
	#define Debug(...) 0
#endif

//=========================================================================================================
// Something about IO

template<typename T>
void read(T &x){
	x=0;T flg=1;
	char ch=getchar();
	while(!isdigit(ch)){if(ch=='-')flg=-1;ch=getchar();}
	while(isdigit(ch))x=(x<<3)+(x<<1)+(ch^48),ch=getchar();
	x*=flg;
}
template<typename T,typename... Args>
void read(T &x,Args &...args){read(x),read(args...);}

//=========================================================================================================
// Define the global variables here.

bool membg=0;
constexpr int N=1e2+7,inf=0x3f3f3f3f;
int n,K,Q,e[N][N];

bool memed=0;

//=========================================================================================================
// Code here.

void solve(){
	read(n,K);
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++)
			read(e[i][j]);
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++)
			if(!e[i][j])e[i][j]=inf;
	for(int k=1;k<=n;k++)
		for(int i=1;i<=n;i++)
			for(int j=1;j<=n;j++)
				e[i][j]=min(e[i][j],e[i][k]+e[k][j]);
	read(Q);
	while(Q--){
		ll x,y;read(x,y);x=(x-1)%n+1,y=(y-1)%n+1;
		printf("%d\n",e[x][y]==inf?-1:e[x][y]);
	}
	return;
}


//=========================================================================================================

int main(){
	Debug("%.3lfMB\n",fabs(&memed-&membg)/1024.0/1024.0);
	int timbg=clock();
	int T=1;
	while(T--)solve();
	int timed=clock();
	Debug("%.3lfs\n",1.0*(timed-timbg)/CLOCKS_PER_SEC);
	fflush(stdout);
	return 0;
}

Submission Info

Submission Time
Task A - Copy and Paste Graph
User EXODUS
Language C++ 17 (gcc 12.2)
Score 300
Code Size 2057 Byte
Status AC
Exec Time 2 ms
Memory 3968 KiB

Compile Error

Main.cpp: In function ‘int main()’:
Main.cpp:18:28: warning: statement has no effect [-Wunused-value]
   18 |         #define Debug(...) 0
      |                            ^
Main.cpp:71:9: note: in expansion of macro ‘Debug’
   71 |         Debug("%.3lfMB\n",fabs(&memed-&membg)/1024.0/1024.0);
      |         ^~~~~
Main.cpp:18:28: warning: statement has no effect [-Wunused-value]
   18 |         #define Debug(...) 0
      |                            ^
Main.cpp:76:9: note: in expansion of macro ‘Debug’
   76 |         Debug("%.3lfs\n",1.0*(timed-timbg)/CLOCKS_PER_SEC);
      |         ^~~~~
Main.cpp:72:13: warning: unused variable ‘timbg’ [-Wunused-variable]
   72 |         int timbg=clock();
      |             ^~~~~
Main.cpp:75:13: warning: unused variable ‘timed’ [-Wunused-variable]
   75 |         int timed=clock();
      |             ^~~~~

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 2
AC × 40
Set Name Test Cases
Sample 00_sample_00.txt, 00_sample_01.txt
All 00_sample_00.txt, 00_sample_01.txt, 01_rnd_00.txt, 01_rnd_01.txt, 01_rnd_02.txt, 01_rnd_03.txt, 01_rnd_04.txt, 01_rnd_05.txt, 01_rnd_06.txt, 01_rnd_07.txt, 02_smallM_00.txt, 02_smallM_01.txt, 02_smallM_02.txt, 02_smallM_03.txt, 02_smallM_04.txt, 03_largeM_00.txt, 03_largeM_01.txt, 03_largeM_02.txt, 03_largeM_03.txt, 03_largeM_04.txt, 04_dag_00.txt, 04_dag_01.txt, 04_dag_02.txt, 04_dag_03.txt, 04_dag_04.txt, 04_dag_05.txt, 04_dag_06.txt, 04_dag_07.txt, 04_dag_08.txt, 04_dag_09.txt, 05_path_00.txt, 05_path_01.txt, 05_path_02.txt, 05_path_03.txt, 06_minmax_00.txt, 06_minmax_01.txt, 06_minmax_02.txt, 06_minmax_03.txt, 06_minmax_04.txt, 06_minmax_05.txt
Case Name Status Exec Time Memory
00_sample_00.txt AC 1 ms 3848 KiB
00_sample_01.txt AC 1 ms 3784 KiB
01_rnd_00.txt AC 1 ms 3892 KiB
01_rnd_01.txt AC 2 ms 3796 KiB
01_rnd_02.txt AC 2 ms 3932 KiB
01_rnd_03.txt AC 2 ms 3892 KiB
01_rnd_04.txt AC 1 ms 3816 KiB
01_rnd_05.txt AC 2 ms 3784 KiB
01_rnd_06.txt AC 1 ms 3760 KiB
01_rnd_07.txt AC 2 ms 3864 KiB
02_smallM_00.txt AC 2 ms 3844 KiB
02_smallM_01.txt AC 2 ms 3820 KiB
02_smallM_02.txt AC 2 ms 3896 KiB
02_smallM_03.txt AC 2 ms 3828 KiB
02_smallM_04.txt AC 2 ms 3744 KiB
03_largeM_00.txt AC 2 ms 3820 KiB
03_largeM_01.txt AC 2 ms 3748 KiB
03_largeM_02.txt AC 2 ms 3804 KiB
03_largeM_03.txt AC 2 ms 3800 KiB
03_largeM_04.txt AC 2 ms 3908 KiB
04_dag_00.txt AC 2 ms 3892 KiB
04_dag_01.txt AC 2 ms 3784 KiB
04_dag_02.txt AC 2 ms 3908 KiB
04_dag_03.txt AC 2 ms 3692 KiB
04_dag_04.txt AC 2 ms 3784 KiB
04_dag_05.txt AC 2 ms 3816 KiB
04_dag_06.txt AC 2 ms 3780 KiB
04_dag_07.txt AC 2 ms 3780 KiB
04_dag_08.txt AC 2 ms 3808 KiB
04_dag_09.txt AC 2 ms 3784 KiB
05_path_00.txt AC 2 ms 3760 KiB
05_path_01.txt AC 2 ms 3964 KiB
05_path_02.txt AC 2 ms 3692 KiB
05_path_03.txt AC 2 ms 3820 KiB
06_minmax_00.txt AC 1 ms 3808 KiB
06_minmax_01.txt AC 1 ms 3896 KiB
06_minmax_02.txt AC 1 ms 3892 KiB
06_minmax_03.txt AC 2 ms 3820 KiB
06_minmax_04.txt AC 2 ms 3968 KiB
06_minmax_05.txt AC 2 ms 3864 KiB