Submission #416851

# Submission time Handle Problem Language Result Execution time Memory
416851 2021-06-03T05:08:35 Z ismoilov Village (BOI20_village) C++14
12 / 100
54 ms 320 KB
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define all(x) (x).begin(), (x).end()
#define fp(a,i,c) for(int (a) = (i); (a) < (c); (a)++)
#define fpp(a,i,c) for(int (a) = (i); (a) <= (c); (a)++)
#define fm(a,i,c) for(int (a) = (i); (a) > (c); (a)--)
#define fmm(a,i,c) for(int (a) = (i); (a) >= (c); (a)--)
#define maxx 100010
int a[11][11];
void S()
{
	int n, ans = 0;
	cin >> n;
	if(n > 10){
		return;
	}
	fp(i,0,n){
		fp(j,0,n)
			a[i][j] = maxx;
		a[i][i] = 0;
	}
	fp(i,1,n){
		int x, y;
		cin >> x >> y;
		x --, y --;
		a[x][y] = 1;
		a[y][x] = 1;
	}
	fp(k,0,n){
		fp(i,0,n){
			fp(j,0,n){
				a[i][j] = min(a[i][j], a[i][k] + a[k][j]);
			}
		}
	}
	vector <int> b, mn_ar, mx_ar;
	fp(i,0,n)
		b.push_back(i);
	int mn = maxx, mx = -maxx;
	do{
		int s = 0;
		bool ok = 1;
		fp(i,0,n){
			if(b[i] == i){
				ok = 0;
				break;
			}
			s += a[i][b[i]];
		}
		if(!ok)
			continue;
		if(s < mn){
			mn = s;
			mn_ar = b;
		}
		if(s > mx){
			mx = s;
			mx_ar = b;
		}
	}while(next_permutation(all(b)));
	cout << mn << " " << mx << "\n";
	fp(i,0,n)
		cout << mn_ar[i] + 1 << " ";
	cout << endl;
	fp(i,0,n)
		cout << mx_ar[i] +1 << " ";
}
int main()
{
	IOS;
	S();
}

Compilation message

Village.cpp: In function 'void S()':
Village.cpp:6:27: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
    6 | #define fp(a,i,c) for(int (a) = (i); (a) < (c); (a)++)
      |                           ^
Village.cpp:19:2: note: in expansion of macro 'fp'
   19 |  fp(i,0,n){
      |  ^~
Village.cpp:6:27: warning: unnecessary parentheses in declaration of 'j' [-Wparentheses]
    6 | #define fp(a,i,c) for(int (a) = (i); (a) < (c); (a)++)
      |                           ^
Village.cpp:20:3: note: in expansion of macro 'fp'
   20 |   fp(j,0,n)
      |   ^~
Village.cpp:6:27: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
    6 | #define fp(a,i,c) for(int (a) = (i); (a) < (c); (a)++)
      |                           ^
Village.cpp:24:2: note: in expansion of macro 'fp'
   24 |  fp(i,1,n){
      |  ^~
Village.cpp:6:27: warning: unnecessary parentheses in declaration of 'k' [-Wparentheses]
    6 | #define fp(a,i,c) for(int (a) = (i); (a) < (c); (a)++)
      |                           ^
Village.cpp:31:2: note: in expansion of macro 'fp'
   31 |  fp(k,0,n){
      |  ^~
Village.cpp:6:27: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
    6 | #define fp(a,i,c) for(int (a) = (i); (a) < (c); (a)++)
      |                           ^
Village.cpp:32:3: note: in expansion of macro 'fp'
   32 |   fp(i,0,n){
      |   ^~
Village.cpp:6:27: warning: unnecessary parentheses in declaration of 'j' [-Wparentheses]
    6 | #define fp(a,i,c) for(int (a) = (i); (a) < (c); (a)++)
      |                           ^
Village.cpp:33:4: note: in expansion of macro 'fp'
   33 |    fp(j,0,n){
      |    ^~
Village.cpp:6:27: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
    6 | #define fp(a,i,c) for(int (a) = (i); (a) < (c); (a)++)
      |                           ^
Village.cpp:39:2: note: in expansion of macro 'fp'
   39 |  fp(i,0,n)
      |  ^~
Village.cpp:6:27: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
    6 | #define fp(a,i,c) for(int (a) = (i); (a) < (c); (a)++)
      |                           ^
Village.cpp:45:3: note: in expansion of macro 'fp'
   45 |   fp(i,0,n){
      |   ^~
Village.cpp:6:27: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
    6 | #define fp(a,i,c) for(int (a) = (i); (a) < (c); (a)++)
      |                           ^
Village.cpp:64:2: note: in expansion of macro 'fp'
   64 |  fp(i,0,n)
      |  ^~
Village.cpp:6:27: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
    6 | #define fp(a,i,c) for(int (a) = (i); (a) < (c); (a)++)
      |                           ^
Village.cpp:67:2: note: in expansion of macro 'fp'
   67 |  fp(i,0,n)
      |  ^~
Village.cpp:14:9: warning: unused variable 'ans' [-Wunused-variable]
   14 |  int n, ans = 0;
      |         ^~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 320 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 5 ms 320 KB Output is correct
10 Correct 49 ms 204 KB Output is correct
11 Correct 48 ms 204 KB Output is correct
12 Correct 54 ms 292 KB Output is correct
13 Correct 49 ms 204 KB Output is correct
14 Correct 49 ms 204 KB Output is correct
15 Correct 49 ms 204 KB Output is correct
16 Correct 49 ms 292 KB Output is correct
17 Correct 48 ms 292 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Unexpected end of file - int64 expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 320 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 5 ms 320 KB Output is correct
10 Correct 49 ms 204 KB Output is correct
11 Correct 48 ms 204 KB Output is correct
12 Correct 54 ms 292 KB Output is correct
13 Correct 49 ms 204 KB Output is correct
14 Correct 49 ms 204 KB Output is correct
15 Correct 49 ms 204 KB Output is correct
16 Correct 49 ms 292 KB Output is correct
17 Correct 48 ms 292 KB Output is correct
18 Incorrect 1 ms 204 KB Unexpected end of file - int64 expected
19 Halted 0 ms 0 KB -