Submission #554965

# Submission time Handle Problem Language Result Execution time Memory
554965 2022-04-29T18:34:35 Z Pietra Group Photo (JOI21_ho_t3) C++14
5 / 100
4 ms 324 KB
#include<bits/stdc++.h>
#define int long long 
using namespace std ; 

const int maxn = 12 ; 
const int inf = 1e18 ; 

int n, ans, v[maxn], go[maxn], test[maxn] ; 

int32_t main(){

	ios_base::sync_with_stdio(false) ; cin.tie(NULL) ; 

	cin >> n ; 

	for(int i = 1 ; i <= n ; i++) cin >> v[i] ; 

	for(int i = 1 ; i <= n ; i++) test[i] = i ; 

    ans = inf ; 

    do{

    	bool ok = 1 ; 

    	for(int i = 1 ; i < n ; i++){
    		if(test[i] >= test[i+1] + 2) ok = 0 ; 
    	}

    	if(!ok) continue ; 

    	for(int i = 1 ; i <= n ; i++){
    		for(int j = 1 ; j <= n ; j++){
    			if(test[i] == v[j]) go[i] = j ; 
    		}
    	}

    	int ct = 0 ; 

    	for(int i = 1 ; i <= n ; i++){
    		for(int j = 1 ; j < i ; j++){
    			if(go[i] < go[j]) ct++ ; 
    		}
    	}

    	ans = min(ans, ct) ; 


    } while(next_permutation(test + 1, test + 1 + n)) ; 

    cout << ans << "\n" ; 

}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 324 KB Output is correct
4 Correct 0 ms 324 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 4 ms 212 KB Output is correct
8 Correct 4 ms 212 KB Output is correct
9 Correct 4 ms 212 KB Output is correct
10 Correct 4 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 324 KB Output is correct
4 Correct 0 ms 324 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 4 ms 212 KB Output is correct
8 Correct 4 ms 212 KB Output is correct
9 Correct 4 ms 212 KB Output is correct
10 Correct 4 ms 212 KB Output is correct
11 Incorrect 1 ms 320 KB Output isn't correct
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 324 KB Output is correct
4 Correct 0 ms 324 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 4 ms 212 KB Output is correct
8 Correct 4 ms 212 KB Output is correct
9 Correct 4 ms 212 KB Output is correct
10 Correct 4 ms 212 KB Output is correct
11 Incorrect 1 ms 320 KB Output isn't correct
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 324 KB Output is correct
4 Correct 0 ms 324 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 4 ms 212 KB Output is correct
8 Correct 4 ms 212 KB Output is correct
9 Correct 4 ms 212 KB Output is correct
10 Correct 4 ms 212 KB Output is correct
11 Incorrect 1 ms 320 KB Output isn't correct
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 324 KB Output is correct
4 Correct 0 ms 324 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 4 ms 212 KB Output is correct
8 Correct 4 ms 212 KB Output is correct
9 Correct 4 ms 212 KB Output is correct
10 Correct 4 ms 212 KB Output is correct
11 Incorrect 1 ms 320 KB Output isn't correct
12 Halted 0 ms 0 KB -