답안 #12664

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
12664 2014-12-27T14:59:48 Z dohyun0324 전선 연결하기 (GA9_wire) C++
9 / 100
1000 ms 1104 KB
#include<stdio.h>
#include<stdlib.h>
int n,arr[1000],a[1010][2],xx[1010];
void dfs(int x)
{
    int i,j;
    if(x==n+1)
    {
        for(i=1;i<=n;i++)
        {
            for(j=1;j<=n;j++)
            {
                if(i==j) continue;
                if(arr[i]==arr[j])
                {
                    if(a[i][0]<a[j][0] && a[j][1]<a[i][1]) continue;
                    if(a[j][0]<a[i][0] && a[i][1]<a[j][1]) continue;
                    if(a[i][0]>a[j][1] || a[j][0]>a[i][1]) continue;
                    return;
                }
            }
        }
        for(i=1;i<=n*2;i++)
        {
            if(arr[xx[i]]==0) printf("^");
            else printf("v");
        }
        exit(0);
    }
    arr[x]=0;
    dfs(x+1);
    arr[x]=1;
    dfs(x+1);
}
int main()
{
    int i;
    scanf("%d",&n);
    for(i=1;i<=n*2;i++)
    {
        scanf("%d",&xx[i]);
        if(a[xx[i]][0]==0) a[xx[i]][0]=i;
        else a[xx[i]][1]=i;
    }
    dfs(1);
    printf("IMPOSSIBLE");
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 1104 KB Output is correct
2 Correct 0 ms 1104 KB Output is correct
3 Correct 0 ms 1104 KB Output is correct
4 Correct 0 ms 1104 KB Output is correct
5 Correct 0 ms 1104 KB Output is correct
6 Correct 0 ms 1104 KB Output is correct
7 Correct 0 ms 1104 KB Output is correct
8 Correct 0 ms 1104 KB Output is correct
9 Correct 0 ms 1104 KB Output is correct
10 Correct 0 ms 1104 KB Output is correct
11 Correct 0 ms 1104 KB Output is correct
12 Correct 0 ms 1104 KB Output is correct
13 Correct 0 ms 1104 KB Output is correct
14 Correct 0 ms 1104 KB Output is correct
15 Correct 0 ms 1104 KB Output is correct
16 Correct 0 ms 1104 KB Output is correct
17 Correct 0 ms 1104 KB Output is correct
18 Correct 0 ms 1104 KB Output is correct
19 Correct 0 ms 1104 KB Output is correct
20 Correct 0 ms 1104 KB Output is correct
21 Correct 0 ms 1104 KB Output is correct
22 Correct 0 ms 1104 KB Output is correct
23 Correct 0 ms 1104 KB Output is correct
24 Correct 0 ms 1104 KB Output is correct
25 Correct 0 ms 1104 KB Output is correct
26 Correct 0 ms 1104 KB Output is correct
27 Correct 0 ms 1104 KB Output is correct
28 Correct 0 ms 1104 KB Output is correct
29 Correct 0 ms 1104 KB Output is correct
30 Correct 0 ms 1104 KB Output is correct
31 Correct 0 ms 1104 KB Output is correct
32 Correct 0 ms 1104 KB Output is correct
33 Correct 0 ms 1104 KB Output is correct
34 Correct 0 ms 1104 KB Output is correct
35 Correct 0 ms 1104 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1000 ms 1100 KB Program timed out
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Halted 0 ms 0 KB -