| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 95945 | Retro3014 | Skyscraper (JOI16_skyscraper) | C++17 | 18 ms | 376 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
#define MAX_N 100
#define DIV 1000000007LL
int N;
vector<int> v;
ll ans;
bool chk[MAX_N+1];
int arr[MAX_N+1];
ll L, L2;
int zero(int x){
return (x>0?x:-x);
}
void dfs(int x){
if(x==N){
if(L>=L2){
ans++;
return;
}
}else{
for(int i=0; i<N; i++){
if(!chk[i]){
arr[x] = i;
chk[i] = true;
if(x!=0){
L2+=(ll)zero(v[arr[x]]-v[arr[x-1]]);
}
dfs(x+1);
chk[i] = false;
if(x!=0){
L2-=(ll)zero(v[arr[x]]-v[arr[x-1]]);
}
arr[x] = 0;
}
}
}
}
void solve1(){
dfs(0);
return;
}
void solve2(){
return;
}
int main(){
scanf("%d%lld", &N, &L);
for(int i=0; i<N; i++){
int x; scanf("%d", &x); v.push_back(x);
}
if(N<=8){
solve1();
}else{
solve2();
}
printf("%lld", ans);
return 0;
}
컴파일 시 표준 에러 (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... | ||||
