제출 #1261499

#제출 시각아이디문제언어결과실행 시간메모리
1261499SmuggingSpunGroup Photo (JOI21_ho_t3)C++20
5 / 100
102 ms10172 KiB
#include<bits/stdc++.h>
#define taskname "C"
using namespace std;
int n;
namespace sub1{
	void solve(){
		vector<int>a(n);
		map<vector<int>, int>f;
		for(int& x : a){
			cin >> x;
		}
		f[a] = 1;
		queue<vector<int>>q;
		q.push(a);
		while(!q.empty()){
			a = q.front();
			q.pop();
			bool flag = true;
			int init = f[a];
			for(int i = 1; i < n; i++){
				if(a[i - 1] > a[i] + 1){
					flag = false;
				}
				swap(a[i - 1], a[i]);
				if(f[a] == 0){
					f[a] = init + 1;
					q.push(a);
				}
				swap(a[i - 1], a[i]);
			}
			if(flag){
				return void(cout << init - 1);
			}
		}
	}
}
namespace sub2345{
	const int lim = 5e3 + 5;
	int a[lim], dp[lim];
	void solve(){
		for(int i = 1; i <= n; i++){
			cin >> a[i];
		}
	}
}
int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	if(fopen(taskname".inp", "r")){
		freopen(taskname".inp", "r", stdin);
	}
	cin >> n;
	if(n <= 9){
		sub1::solve();
	}
	else{
		sub2345::solve();
	}
}

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

Main.cpp: In function 'int main()':
Main.cpp:49:24: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   49 |                 freopen(taskname".inp", "r", stdin);
      |                 ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...