# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1261499 | SmuggingSpun | Group Photo (JOI21_ho_t3) | C++20 | 102 ms | 10172 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) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |