All Discussions - algospot.com http://www.algospot.com/discussions/feed.rss Fri, 10 Feb 12 18:28:22 -0500 All Discussions - algospot.com en-CA Algospot 2주년 모의고사 - prefix 문제입니다. http://www.algospot.com/discussion/1304/algospot-2%EC%A3%BC%EB%85%84-%EB%AA%A8%EC%9D%98%EA%B3%A0%EC%82%AC-prefix-%EB%AC%B8%EC%A0%9C%EC%9E%85%EB%8B%88%EB%8B%A4. Thu, 02 Feb 2012 01:20:40 -0500 DAEJIN 1304@/discussions
prefix 문제를 풀어보았는데요

WA 인데

아무리 생각해도 이유를 모르겠어서 이렇게 질문올립니다 ㅠ

저에게 도움을 주세요 ~~

-----------------------------------------------------------------------------------------------

#include
#include

#define MAX_NUM_WORDS 3000
#define MAX_LENGTH_WORDS 200

int
matching_count(char word[][MAX_LENGTH_WORDS], int numOfwords, int maxlenOfwords, char *key, int keylen)
{
int count = 0;

if (maxlenOfwords < keylen)
return -1;

for (int i = 0; i < numOfwords; i++) {
if (strlen(word[i]) < keylen)
continue;

if (!strncmp(word[i], key, keylen))
count++;
}

return count;
}

void
printSubstr(char *str, int nth)
{
for (int i = 0; i < nth; i++)
printf("%c", str[i]);
printf("\n");
}

int
main(void)
{
int T;
scanf("%d", &T);

while(T--) {
int numOfwords;
int maxlenOfwords;
char words[MAX_NUM_WORDS][MAX_LENGTH_WORDS];
char *result;

scanf("%d %d", &numOfwords, &maxlenOfwords);
for (int i = 0; i < numOfwords; i++)
scanf("%s", &words[i]);


result = words[0];
for (int i = 1; i <= maxlenOfwords; i++) {<br /> int count = -1;
int nth = -1;
int tmp;

for (int j = 0; j < numOfwords; j++) {
if (nth == i && !strncmp(words[j], result, i))
continue;

int strLen = strlen(words[j]);
if (strLen > maxlenOfwords)
break;
else if ((tmp = matching_count(words, numOfwords, maxlenOfwords, words[j], i)) > count) {
result = words[j];
nth = i;
count = tmp;
} else if (tmp == count) {
if (strncmp(result, words[j], i) > 0)
result = words[j];
}
}

printSubstr(result, nth);
}
}

return 0;
}

-----------------------------------------------------------------------------------------------]]>
여러분은 연습때 한 문제에 시간을 얼마나 투자하고 그 이유는 무엇인가요? http://www.algospot.com/discussion/1303/%EC%97%AC%EB%9F%AC%EB%B6%84%EC%9D%80-%EC%97%B0%EC%8A%B5%EB%95%8C-%ED%95%9C-%EB%AC%B8%EC%A0%9C%EC%97%90-%EC%8B%9C%EA%B0%84%EC%9D%84-%EC%96%BC%EB%A7%88%EB%82%98-%ED%88%AC%EC%9E%90%ED%95%98%EA%B3%A0-%EA%B7%B8-%EC%9D%B4%EC%9C%A0%EB%8A%94-%EB%AC%B4%EC%97%87%EC%9D%B8%EA%B0%80%EC%9A%94 Tue, 24 Jan 2012 05:22:22 -0500 VOCList 1303@/discussions
저같은 경우에는 문제에 딱히 시간 제한을 두기보다는 혼자 지칠때까지 잡고 있다가 솔우션을 찾아보거나 그냥 잊어버리거나 하는 경우가 대부분인 것 같습니다.
풀던 문제를 너무 간단히 솔루션을 보는 건 왠지 내키지 않기도 하고, 이른바 문제 낭비가 될 수도 있기 때문에 조심스러운 반면,
기약없이 계속 잡고있을 때에는 못푸는 문제는 결국 못풀고 잊어버리는 경우가 많게 되더라고요.

그래서 이번 연습에는, 일단 실제 대회에서 실질적으로 한 문제를 잡고 있을 수 있는 시간은 2~3시간이 한계라고 생각하고 그 정도에서 시간 제한을 두고 솔루션을 참고하는 방향으로 진행해볼까 합니다.

아마 저 말고도 많은 분들이 해 보셨을 고민일 것 같아서, 같은 고민을 해보신 분들의 의견을 공유하고 싶네요.

감사합니다.
새해 복 많이 받으세요. :)]]>
기하 관련 문제 질문입니다. http://www.algospot.com/discussion/1299/%EA%B8%B0%ED%95%98-%EA%B4%80%EB%A0%A8-%EB%AC%B8%EC%A0%9C-%EC%A7%88%EB%AC%B8%EC%9E%85%EB%8B%88%EB%8B%A4. Sat, 14 Jan 2012 09:51:11 -0500 Chaos.PP 1299@/discussions
문제에 대해 먼저 설명 드리겠습니다.
---------------------------------------------------------------
문제는 2차원 평면에서 N개의 원이 존재하는데요, N개의 원들은 임의의 반지름을

가지고 있습니다. 그리고 원들은 우선순위가 존재합니다. 즉, 정렬하여 먼저 그려야

하는 원이 무엇인지 알 수 있습니다. 이렇게 원과 반지름, 우선순위가 주어졌고,

그리기 시작하는 가장 가까운 반경이 주어졌을 때, 가장 가까운 반경부터 우선순위가

높은 원부터 다른 원들과 겹치지 않고 바깥쪽으로 그려 나가야 합니다. 출력으로 각

원들의 중심점만 알 수 있다면 충분합니다. 원과 원은 한점에서 접해도 상관 없습니다.
---------------------------------------------------------------
위와같은 문제에 대한 적절한 솔루션이 생각나질 않습니다ㅠ. 혹시 조그마한 조언이라도

주신다면 감사하겠습니다.
]]>
srm 캘린더는.. http://www.algospot.com/discussion/1302/srm-%EC%BA%98%EB%A6%B0%EB%8D%94%EB%8A%94.. Thu, 19 Jan 2012 01:11:33 -0500 ibroker 1302@/discussions 혹시 topcoder에서 제공하는 거라면, 주소라도 알려주시면 감사! ㅎ]]> 채점 되는지 확인부탁드려요! http://www.algospot.com/discussion/1301/%EC%B1%84%EC%A0%90-%EB%90%98%EB%8A%94%EC%A7%80-%ED%99%95%EC%9D%B8%EB%B6%80%ED%83%81%EB%93%9C%EB%A0%A4%EC%9A%94 Wed, 18 Jan 2012 02:19:45 -0500 hiwaryi 1301@/discussions Google Developers University Hackathon이 열립니다! http://www.algospot.com/discussion/1300/google-developers-university-hackathon%EC%9D%B4-%EC%97%B4%EB%A6%BD%EB%8B%88%EB%8B%A4 Tue, 17 Jan 2012 09:31:16 -0500 legend12 1300@/discussions - 참가 대상: 대학생
- 참가 신청 단위: 개인 혹은 팀

일정
- 2월 7일(화) ~ 13일(월): 참가 신청 접수
- 2월 14일(화): 참가자 선정 결과 발표
- 2월 21일(화): 프로젝트 발표 (장소: 구글코리아)
- 2월 25일(토): 해커톤 본 행사 & 뒷풀이 (장소: 구글코리아)


자세한 사항은 링크를 참조해주세요.

http://googledevkr.blogspot.com/2012/01/google-developers-university-hackathon.html]]>
ID: DECODE 문제 질문입니다. http://www.algospot.com/discussion/1295/id-decode-%EB%AC%B8%EC%A0%9C-%EC%A7%88%EB%AC%B8%EC%9E%85%EB%8B%88%EB%8B%A4.- Mon, 26 Dec 2011 22:03:04 -0500 boykyd 1295@/discussions
이게 무슨 의미죠? space를 다 '\0'로 채우라는 의미 인가요?]]>
Avoid Your Professor 문제 질문입니다. http://www.algospot.com/discussion/1298/avoid-your-professor-%EB%AC%B8%EC%A0%9C-%EC%A7%88%EB%AC%B8%EC%9E%85%EB%8B%88%EB%8B%A4.- Sat, 14 Jan 2012 06:49:51 -0500 코시 1298@/discussions 아.. 어디가 틀렸는지 좀 봐주실수 있으신가요?

다익스트라로 돌리면서 이전 index값 찾고 그걸 가지고 카운팅했는데.. WA가 나오네요.

한번 어디가 틀렸는지 찾아봐주실수 있으신가요? ㅠ.ㅠ
부탁드립니다;;


#include
#include
#include
#include
#include

#define MAX 101
#define INT_MAX 9999999

using namespace std;

int V;
int E;
int N;

int g[MAX][MAX];
int in[MAX];
int cost[MAX];
set indexes[MAX];

int cnt[MAX];

priority_queue, vector >, greater > > que;

int gcd(int m, int n)
{
while (n != 0)
{
int r = m % n;
m = n;
n = r;
}

return m;
}

int calcCnt(int n)
{
int temp = 0;
if ( indexes[n].size() > 0 )
{
for (set::iterator it = indexes[n].begin(); it != indexes[n].end(); it ++)
{
temp += calcCnt(*it);
}
}
else
{
temp = 1;
}

cnt[n] += temp;

return temp;
}

void solve()
{
memset(cnt, 0, sizeof(cnt));
for(int i = 0; i <= N; i ++)<br /> {
indexes[i].clear();
}

for(int i = 0; i <= V; i ++)<br /> {
cost[i] = INT_MAX;
}

que.push(make_pair(0, 1));
while (!que.empty())
{
pair now = que.top();
que.pop();

if ( cost[now.second] < now.first )
{
continue;
}

for ( int i = 1; i <= V; i ++)<br /> {
if (g[now.second][i] != 0)
{
int temp = now.first + g[now.second][i];

if (cost[i] >= temp)
{
cost[i] = temp;

que.push(make_pair(temp, i));
indexes[i].insert(now.second);
}
}
}
}

calcCnt(V);

for (int i = 0; i < N; i ++)
{
int gcdValue = gcd(cnt[V], cnt[in[i]]);
printf("%d/%d\n", cnt[in[i]]/gcdValue, cnt[V]/gcdValue);
}
}

int main()
{
int c;
scanf("%d", &c);
while (c--)
{
scanf("%d %d %d", &V, &E, &N);

memset(g, 0, sizeof(g));
for (int i = 0; i < E; i ++)
{
int s, t, v;
scanf("%d %d %d", &s, &t, &v);

g[s][t] = v;
}

for (int i = 0; i < N; i ++)
{
scanf("%d", &in[i]);
}

solve();
}

return 0;
}
]]>
LIS 문제 질문이요. http://www.algospot.com/discussion/1297/lis-%EB%AC%B8%EC%A0%9C-%EC%A7%88%EB%AC%B8%EC%9D%B4%EC%9A%94. Fri, 30 Dec 2011 11:29:04 -0500 safariworld 1297@/discussions http://algospot.com/problems/read/LIS
Python으로 N이 500이길래 그냥 O(N^2)에 짰습니다. ( 물론 Test case는 미포함.) 그런데 TLE가 뜨네요 ㅠㅠ
다른데서 시간이 더 걸릴것 같지는 않은데... 살려주세요 ㅠㅠ

import sys

r1 = lambda: sys.stdin.readline().strip()
T = int(r1())

for _ in range(T):
N = int(r1())
d=[]
ans = 0
a = r1().split(' ')
for i in range(N):
maxv = 0
for j in range(i):
if int(a[j]) < int(a[i]):
maxv = max(maxv, d[j])
d.append(maxv+1)
for i in range(N):
ans = max(ans, d[i])
print ans]]>
Quantization 문제 설명 보충부탁드립니다 http://www.algospot.com/discussion/1296/quantization-%EB%AC%B8%EC%A0%9C-%EC%84%A4%EB%AA%85-%EB%B3%B4%EC%B6%A9%EB%B6%80%ED%83%81%EB%93%9C%EB%A6%BD%EB%8B%88%EB%8B%A4 Tue, 27 Dec 2011 13:11:52 -0500 co2meal 1296@/discussions
라고 되어있는데요

S개의 양자화 된 값이 모두 달라야하는지 같아도 괜찮은지 표시가 안되어있네요

예를들어

1 1 1 1 1 으로 구성된 수열에서 S가 2라면

양자화된 수열은

1 1 1 1 2 인지 1 1 1 1 1..인지

전자의 경우엔 S에 맞추려고 일부러 ... 망한 케이스네요


후자라면 "... S 개 이하의 값만을 사용하도록 ..." 으로 고쳐주셨으면 좋을거같네요]]>
ID: DECODE 문제 WA뜨는데 소스좀 봐주세요. http://www.algospot.com/discussion/1294/id-decode-%EB%AC%B8%EC%A0%9C-wa%EB%9C%A8%EB%8A%94%EB%8D%B0-%EC%86%8C%EC%8A%A4%EC%A2%80-%EB%B4%90%EC%A3%BC%EC%84%B8%EC%9A%94.- Mon, 26 Dec 2011 05:12:42 -0500 boykyd 1294@/discussions
입력된 코드를 2차원으로, 암호를 풀기위한 규칙에 따라
코드를 재배열 한 후에 재배열된 코드를 5개씩 끊어서 암호를 풀었는데요.
WA가뜨네요.
뭐가 문제일까요?

혹시 이 문제 AC받으신분 코드좀 공유해 주시면 안될까요?

#include

int main()
{

int N;
int r;
int c;
int d;

int left, top, bottom, right;


int x, y;
int i;

char code[400];
char sorted_code[400];
int code_length;

int base;
int decode;
int str_idx;


char msg[100];

scanf("%d", &N);

for(i=0; i {
scanf("%d", &r);
scanf("%d", &c);
scanf("%s", code);

left=0;
right=c;
top=0;
bottom=r;

code_length=0;
while(top {
for(d=0; d<4; d++)<br /> {
if(d==0)
{
for(x=left; x sorted_code[code_length++]=code[top*c+x];

top++;
}
else if(d==1)
{
for(y=top; y sorted_code[code_length++]=code[y*c+(right-1)];

right--;
}
else if(d==2)
{
for(x=right-1; x>=left; x--)
sorted_code[code_length++]=code[(bottom-1)*c+x];

bottom--;
}
else{
for(y=bottom-1; y>=top; y--)
sorted_code[code_length++]=code[y*c+left];

left++;
}
}//end for loop
}//end while loop

base=16;
decode=0;
str_idx=0;
for(x=0; x<=code_length; x++)<br /> {
if(base==0)
{
if(decode==0) msg[str_idx++]=' ';
else msg[str_idx++]=decode+'A'-1;

base=16;
decode=0;
}

decode=decode+(sorted_code[x]-'0')*base;
base=base/2;
}

msg[str_idx]='\0';
printf("%d %s\n",i+1, msg);
}

return 0;
}//end of main

]]>
MM 캠프 대회 결과 http://www.algospot.com/discussion/1293/mm-%EC%BA%A0%ED%94%84-%EB%8C%80%ED%9A%8C-%EA%B2%B0%EA%B3%BC Sat, 17 Dec 2011 11:26:19 -0500 일루 1293@/discussions http://libe.lavida.us/mmjudge/problem.php

http://libe.lavida.us/mmjudge/standing_final.php

참가자 여러분들 모두 수고하셨습니다! (중간에 가신 nicola님도...)

리베님도 시스템 셋팅 감사드려요 ㅋㅋ

다음 캠프는 아침부터 막바로 대회 형식으로 진행하려고 합니다. 1월 말쯤이 될 것 같습니다.]]>
Freehug 문제인데요.. http://www.algospot.com/discussion/1292/freehug-%EB%AC%B8%EC%A0%9C%EC%9D%B8%EB%8D%B0%EC%9A%94.. Fri, 16 Dec 2011 11:06:53 -0500 chajaeyoung 1292@/discussions
자꾸 이게뜨는데


#include<stdio.h>
#include<string.h>
#include<stdlib.h>

int freehug(char *ary1, char *ary2);
void aryplus(char *ary1);

int main()
{
char ary1[300000];
char ary2[300000];
int t,a,b,c;
int count=0;

scanf("%d",&t);

for(int i=0; i<t; i++)
{
scanf("%s",ary1);
scanf("%s",ary2);

if(t>20)
{
printf("프로그램을 종료합니다.");
goto end;
}


a=strlen(ary1);
b=strlen(ary2);
if(a>b)
{
printf("프로그램을 종료합니다.");
goto end;
}
c=b-a;

for(int i=0; i<=c; i++)
{
if(freehug(ary1,ary2)==0)
{
count+=1;
}
aryplus(ary1);
ary1[i]='F';
}

printf("%d\n",count);

count=0;
a=0;
b=0;
c=0;

free(ary1);
free(ary2);

}

end:

return 0;
}

int freehug(char *ary1, char *ary2)
{
int a=0;

for(int i=0; ary1[i] != NULL; i++)
{
if(ary1[i]=='M')
{
if(ary2[i]=='M')
{
a+=1;
}
else
{
a+=0;
}
}
else
{
a+=0;
}
}
return a;
}

void aryplus(char *ary1)
{
int a;
a=strlen(ary1);

ary1[a]=0;


for(int i=0; i<=a; i++)
{
ary1[a+1-i]=ary1[a-i];
}
}

이게 소스랍니다 뭐가 문제죠 ㅠㅠ]]>
MM 캠프 2회차 문제입니다. + 12월 17일 대회 안내 http://www.algospot.com/discussion/1291/mm-%EC%BA%A0%ED%94%84-2%ED%9A%8C%EC%B0%A8-%EB%AC%B8%EC%A0%9C%EC%9E%85%EB%8B%88%EB%8B%A4.-12%EC%9B%94-17%EC%9D%BC-%EB%8C%80%ED%9A%8C-%EC%95%88%EB%82%B4 Mon, 05 Dec 2011 07:38:29 -0500 일루 1291@/discussions

2회차 문제도 탑코더 문제입니다. (자체 시스템이 구축되기 전까지는..)

이번 문제는 MM62 - CellularAutomaton 입니다.

http://community.topcoder.com/longcontest/?module=ViewPractice 를 참고해주세요.

문제: http://community.topcoder.com/longcontest/?module=ViewProblemStatement&rd=14348&pm=10989
제출: http://community.topcoder.com/longcontest/?module=Submit&compid=12783&rd=14348&cd=13341
연습방 순위: http://community.topcoder.com/longcontest/?module=ViewStandings&rd=14348
실제 대회 순위: http://community.topcoder.com/longcontest/stats/?module=ViewOverview&rd=14273


제출 기한은 12월 16일 금요일 밤 11시 59분 59초까지입니다.


몇 가지 주의사항을 남기겠습니다. (재탕)

1. Example test는 15분에 한번, Full Submission은 2시간에 한번씩만 할 수 있습니다.

2. 제출은 아레나에서 하지 마시고 위의 'Submit' 링크를 따라가서 제출하시기 바랍니다. 아레나는 쓸모가 없다능...

3. 이 MM의 경우에는 예쁜 Tester가 있습니다. (problem statement 중간에 사용법 있음) 사용법을 꼭 익혀두세요.

4. 로컬 테스트를 많이 해주세요. 예제를 랜덤하게 생성해서 돌리는 스크립트를 만들어두면 좋습니다.



이 문제는 Simulated Annealing이 주요 해법인 문제입니다. 다른 방법을 시도해 보셔도 좋습니다.

질문은 언제든지 환영입니다!


ps) 지난 주 토요일에 1주차 코딩 하시던 분들은 제출 부탁드려요 ^^;;


------

+ 12월 17일 일정은 다음과 같습니다.

오전 10시-오후 12시 30분 - 강의 & 지난 MM 설명
오후 12시 30분~1시 30분 - 점심시간
오후 1시 30분~오후 10시 - 대회! - 중간에 치킨이랑 피자옵니당...

이 날의 참가비는 4만원입니다.

참가하실 분들은 코멘트를 달아주세요.]]>
MM 캠프 1회차 문제입니다. http://www.algospot.com/discussion/1290/mm-%EC%BA%A0%ED%94%84-1%ED%9A%8C%EC%B0%A8-%EB%AC%B8%EC%A0%9C%EC%9E%85%EB%8B%88%EB%8B%A4. Mon, 28 Nov 2011 00:12:59 -0500 일루 1290@/discussions
1회차 문제는 탑코더 문제입니다.

토너먼트 라운드가 아닌 라운드 치고는 참여자가 매우 많았던 MM58 - IsolatedPrimes 입니다.

http://community.topcoder.com/longcontest/?module=ViewPractice 의 'Marathon Match 58' 줄에서 문제를 보고, 제출을 하고, 실제와 연습방 스탠딩도 보실 수 있습니다.

제출 기한은 토요일 밤 11시 59분 59초까지입니다.

참여하시는 분들은 코멘트로 탑코더 아이디를 남겨주시기 바랍니다 ^^;


몇 가지 주의사항을 남기겠습니다.

1. Example test는 15분에 한번, Full Submission은 2시간에 한번씩만 할 수 있습니다.

2. 제출은 아레나에서 하지 마시고 위의 'Submit' 링크를 따라가서 제출하시기 바랍니다. 아레나는 쓸모가 없다능...

3. 이 MM의 경우에는 Tester가 없습니다만, example test로 대신해주시기 바랍니다.

4. 로컬 테스트를 많이 해주세요. 예제를 랜덤하게 생성해서 돌리는 스크립트를 만들어두면 좋습니다.

5. 포럼을 보면 예전 대회때의 글들을 볼 수 있는데, 연습이니만큼 보지 말고 스스로 짜주세요. 관련 논문 등 검색도 하지 않아주셨으면 좋겠습니다~

문제 풀이법이 아닌 다른 질문은 언제든지 환영입니다!


그럼 열심히 하시고 토요일에 뵙도록 하겠습니다.]]>
MM 캠프 합니다! http://www.algospot.com/discussion/1288/mm-%EC%BA%A0%ED%94%84-%ED%95%A9%EB%8B%88%EB%8B%A4 Tue, 22 Nov 2011 22:51:07 -0500 일루 1288@/discussions
12월에 MM이 두 개가 있다고 공표가 된 상황이고, 여론을 살펴보니 참가 의향이 있는 분들이 어느 정도 있는 듯 하여 진행합니다.

일정은 다음과 같은데 실제 MM 일정에 따라 바뀔 수 있습니다.

11.26(토)~12.2(금) : 연습용 MM을 하나 합니다.
12.3(토) 오전10-오후3 - 연습한 MM에 대해 토의하고, 강의를 듣습니다.
12.4(일)~12.16(금) : 연습용 MM을 하나 합니다.
12.17(토) 오전10-오후10 - 연습한 MM에 대해 토의하고, 강의를 듣습니다. 오후시간엔 MM을 하나 합니다. (그날 밤에 스름이 있으니 빡센 일정이 되겠죠?)
12.21(수)~1.4(수) : MM75를 합니다.
1.7(토) 오전10-오후3 - 진행한 MM에 대해 토의하고, 강의를 듣습니다.

토요일 세션은 구글코리아에서 할 예정입니다. 오전 10시에 역삼동 강남파이낸스센터 22층 정문 앞에서 뵙죠.

*연습MM에 참가하지 않았다면 세션 참가가 불가능합니다.

세션 참가비는 각각 2, 4, 2만원입니다. 식비와 간식비는 포함되어 있습니다. 12.17의 대회 상금으로 어느 정도 지출될 수도 있습니다.


일단 참가 의향이 있는 분들은 코멘트를 달아주시기 바랍니다.]]>
Stack과 Thread를 이용한 경우의 수 구하기 문제입니다. http://www.algospot.com/discussion/1289/stack%EA%B3%BC-thread%EB%A5%BC-%EC%9D%B4%EC%9A%A9%ED%95%9C-%EA%B2%BD%EC%9A%B0%EC%9D%98-%EC%88%98-%EA%B5%AC%ED%95%98%EA%B8%B0-%EB%AC%B8%EC%A0%9C%EC%9E%85%EB%8B%88%EB%8B%A4. Thu, 24 Nov 2011 04:38:53 -0500 donemin 1289@/discussions == 문제 설명 ==

어떤 프로그램이 있다. 이 프로그램은 두 개의 쓰레드가 내부적으로 돌고 있다. A쓰레드는 Stack에 1~N까지의 숫자를 순서대로 Stack에 계속 쌓고, 다른 B쓰레드는 이 Stack에서 숫자를 꺼내서 출력하게 된다. 두 쓰레드가 숫자를 넣고 꺼내는 시간 간격은 아주 랜덤하다.

예를 들어 N이 5일 때,
A가 1, 2, 3을 넣는다.
B가 3, 2를 꺼내어 출력한다.
A가 4, 5을 넣는다
B는 5, 4, 1를 꺼내어 출력한다
인 경우라면 출력은 3 2 5 4 1 이다

여기서 특정 N에 대해서 출력 가능한 형태를 모두 출력하는 프로그램을 작성한다.

다음은 N의 값이 3일 때의 출력 결과 이다.

N 이 3 일 경우 출력 할 수 있는 결과는
A(1) -> B(1) -> A(2) -> B(2) -> A (3) -> B(3) => 1 2 3
A(1) -> B(1) -> A (2, 3) -> B(3, 2) => 1 3 2
A(1, 2) -> B(2, 1) -> A (3) -> B(3) => 2 1 3
A(1, 2) -> B(2) -> A(3) -> B(3, 1) => 2 3 1
A(1, 2, 3) -> B(3, 2, 1) => 3 2 1
이렇게 5가지 경우가 출력되게 된다.

== 입력 ==
입력은 여러 케이스로 구성되어 있다. 각 케이스별 N(1~ 16) 의 값이 나오게 되고, 만약 0이 입력되면 프로그램을 종료한다.

== 출력 ==
출력은 가능한 모든 케이스를 작은 수부터 출력한다. 각 케이스는 빈 라인으로 구분한다.


이상이 문제인데요

제가 생각한 방법은 트리를 통해 모든 경우의 수를 출력후 재귀로 돌리려했는데

소스코드가 좀처럼 잘 짜여지지 않네요

도움주실분이나 해법을 함께 생각해 주실분 ^ㅁ^) 저는 java로 코딩중입니당

고수님들 도와주세요!

풀이법이나 해법 함께 공유했으면 합니다.]]>
Bipartite Graph에서의 변형된 Vertex cover문제 http://www.algospot.com/discussion/1286/bipartite-graph%EC%97%90%EC%84%9C%EC%9D%98-%EB%B3%80%ED%98%95%EB%90%9C-vertex-cover%EB%AC%B8%EC%A0%9C Fri, 11 Nov 2011 03:43:55 -0500 Agidari 1286@/discussions
오랫동안 생각을 하다 적절한 사이트를 찾아 질문을 올립니다 -_-;

아마 알고리즘 공부를 하다 보면 한번쯤은 생각해보신 문제일거라 생각합니다..

Bipartite Graph G(P, Q, E)가 있습니다. P와 Q는 각각 노드 집합이며 E는 P -> Q인 (뭐 undirectional이라도 상관없지만..) edge 집합입니다.

이 때, P에서 최소 갯수의 노드를 골라 Q가 모두 선택되도록 하고 싶습니다.

Vertex cover를 찾아보았으나 그 알고리즘은 노드를 P와 Q 모두에서 찾더군요..


좋은 방법이 없을까요?ㅎ]]>
온라인 저지 구축 방법 좀 알 수 있을까요? http://www.algospot.com/discussion/1285/%EC%98%A8%EB%9D%BC%EC%9D%B8-%EC%A0%80%EC%A7%80-%EA%B5%AC%EC%B6%95-%EB%B0%A9%EB%B2%95-%EC%A2%80-%EC%95%8C-%EC%88%98-%EC%9E%88%EC%9D%84%EA%B9%8C%EC%9A%94 Wed, 09 Nov 2011 06:43:33 -0500 Chaos.PP 1285@/discussions
쉽게 구축할 수 있는 방법 좀 알 수 있을까요? ]]>
아.. 이문제 도저히 못풀겠습니다.... http://www.algospot.com/discussion/1287/%EC%95%84..-%EC%9D%B4%EB%AC%B8%EC%A0%9C-%EB%8F%84%EC%A0%80%ED%9E%88-%EB%AA%BB%ED%92%80%EA%B2%A0%EC%8A%B5%EB%8B%88%EB%8B%A4.... Fri, 11 Nov 2011 15:02:36 -0500 Moku 1287@/discussions http://acm.uva.es/p/v104/10453.html

아.... 중간에 글씨 넣는건 도대체 어떻게 체크해야하는거죠.... ㅠ]]>
. http://www.algospot.com/discussion/1284/. Sun, 06 Nov 2011 20:00:04 -0500 pinetree 1284@/discussions POKTANJU 데이터 확인 해주세요. http://www.algospot.com/discussion/1281/poktanju-%EB%8D%B0%EC%9D%B4%ED%84%B0-%ED%99%95%EC%9D%B8-%ED%95%B4%EC%A3%BC%EC%84%B8%EC%9A%94. Tue, 01 Nov 2011 12:22:58 -0400 pinetree 1281@/discussions 뭔가 쉬운 문제 같은데 맞으신 분이 없어서.....]]> 2011 ACM-ICPC Daejeon regional livecast! http://www.algospot.com/discussion/1283/2011-acm-icpc-daejeon-regional-livecast Fri, 04 Nov 2011 21:12:37 -0400 최치선 1283@/discussions http://shovel.redfeel.net/~libe/daejeon11
]]>
남극 기지 질문입니다! 제 생각에는 맞는거 같은데요... ㅠㅠ http://www.algospot.com/discussion/1282/%EB%82%A8%EA%B7%B9-%EA%B8%B0%EC%A7%80-%EC%A7%88%EB%AC%B8%EC%9E%85%EB%8B%88%EB%8B%A4-%EC%A0%9C-%EC%83%9D%EA%B0%81%EC%97%90%EB%8A%94-%EB%A7%9E%EB%8A%94%EA%B1%B0-%EA%B0%99%EC%9D%80%EB%8D%B0%EC%9A%94...-%E3%85%A0%E3%85%A0 Fri, 04 Nov 2011 02:43:33 -0400 Baek 1282@/discussions 알고리즘은 일단 맞는것 같습니다.(풀고 나서 인터넷 뒤져보니 나오더군요)

다른점이 있다면 인터넷에서 찾은것은 각 기지들의 모든 거리를 저장하여 트리를 구성한 후
각 기지에서 가장 근접한 기지의 거리들 중, 가장 긴 거리를 찾고 있는거 같구요

제가 작성한 것은 각 기지에서 모든 기지의 거리를 구할 때, 각 기지에서 가장 가까운 기지의 거리만 들고 있다가, (트리 구성 안함)
그 중에서 가장 긴 거리를 출력했거든요...

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;


public class Main {
static long MAX = 1000;
public static void main(String[] args) throws NumberFormatException, IOException {
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));

int 테스트케이스 = Integer.parseInt(in.readLine());
while(테스트케이스-- != 0) {
int 모든_점의_갯수 = Integer.parseInt(in.readLine());

double[][] 모든_점들의_위치 = new double[모든_점의_갯수][2];
for(int i = 0; i < 모든_점의_갯수; i++) {
String[] ret = in.readLine().split(" ");
모든_점들의_위치[i][0] = Double.parseDouble(ret[0]);
모든_점들의_위치[i][1] = Double.parseDouble(ret[1]);
}

double 가장_먼_거리_즉_결과 = 0;
double[] 해당_점에서_가장_가까운_점과의_거리 = new double[모든_점의_갯수];
for(int i = 0; i < 모든_점의_갯수; i++) {
해당_점에서_가장_가까운_점과의_거리[i] = Double.MAX_VALUE;
for(int j = i + 1; j < 모든_점의_갯수; j++) {
double 특정_두_점끼리의_거리 = Math.pow((모든_점들의_위치[i][0] - 모든_점들의_위치[j][0]), 2) + Math.pow((모든_점들의_위치[i][1] - 모든_점들의_위치[j][1]), 2);
if(해당_점에서_가장_가까운_점과의_거리[i] > 특정_두_점끼리의_거리) {
해당_점에서_가장_가까운_점과의_거리[i] = 특정_두_점끼리의_거리;
}
}

if(해당_점에서_가장_가까운_점과의_거리[i] == Double.MAX_VALUE) {
해당_점에서_가장_가까운_점과의_거리[i] = 0;
}

if(가장_먼_거리_즉_결과 < 해당_점에서_가장_가까운_점과의_거리[i]) {
가장_먼_거리_즉_결과 = 해당_점에서_가장_가까운_점과의_거리[i];
}
}

System.out.println(String.format("%.2f", Math.sqrt(가장_먼_거리_즉_결과)));
}
in.close();
}
}]]>
JAG Practice Contest 2011 공지 http://www.algospot.com/discussion/1280/jag-practice-contest-2011-%EA%B3%B5%EC%A7%80 Sat, 22 Oct 2011 11:58:57 -0400 VOCList 1280@/discussions
-------

ACM-ICPC Japanese Alumni Group will host the JAG Practice Contest on
November 6 which targets ACM-ICPC Asia Regional Contest 2011, Fukuoka Site.
We are now calling for teams that participate in the contest.

** DATE AND PLACE

- Date: Sunday, November 6, 2011.
- Time: The contest will start at 11:00 Japan Standard Time (UTC+9).
- Place: Seminar room, Mixi, Inc.
http://mixi.co.jp/profile/info/#map
(Remote teams can take part in the contest via the Internet.)

** SCHEDULE

- 09:00-- Preparation
- 09:30-- Test session (1 hour)
- 11:00-- JAG Practice Contest
- 16:30-- Commentary on the problems (on-site, Ustream is planned)

** LANGUAGE

The problem statement and clarifications will be presented in English.
The commentary will be provided only in Japanese.

** ELIGIBILITY

- Teams participating in the ACM-ICPC Regional Contests 2011.
- Motivated teams working their way to win the Regional Contests held
in the next year, 2012.

** REGISTRATION

To participate in the contest, you should register at this page:
https://docs.google.com/spreadsheet/viewform?formkey=dGZPMzJfTG5HX0lJdmNtWkRWOGs1aVE6MQ

The registration deadline is Wednesday, November 2, 2011, 17:00 JST.
Registration after the deadline will not be accepted.

** FEE

Free of charge.

** PARTICIPATION

- All teams should use PC^2 9.1.6 ( http://www.ecs.csus.edu/pc2/ ), so
please learn how to use it beforehand.
- The submitted program will be compiled with gcc4/MinGW (C, C++) and
JDK6 (Java).

** ON-SITE TEAMS

- We will not provide computers for you. Please bring at least one laptop
for each team.
- Wireless network connection will be used.

** REMOTE TEAMS

- Online teams should take part in the connection test.
- Please test connection from 11/4 20:00 to 11/6 09:00.
We recommend that you test it early.
- We do not set problems on the connection test.

We welcome your participation, and we hope you enjoy the contest.

---------

그나저나 대회 장소가 믹시 사무실이네요 ㅠㅠ 우리도 저런거 스폰해주는 회사 있었으면 좋겠다...]]>
2011 ACM-ICPC Daejeon Regional Warm-up Contest http://www.algospot.com/discussion/1279/2011-acm-icpc-daejeon-regional-warm-up-contest Wed, 12 Oct 2011 01:24:39 -0400 Being 1279@/discussions Problemset
http://algospot.com/contest/2011warmup/problems.pdf

You can submit in the AOJ now! : http://algospot.com/problems/source/Algospot+ICPC+Seoul+Regional+Warmup+2011

Contest Result


The contest is over! We are very sorry for the inconvenience about severe issues about the problem.
You can view preliminary result here.
All the problems will be uploaded in a soon, and will be notified here.
Thanks!

대회가 종료되었습니다. 대회 도중 발생한 심각한 문제들에 대해 깊은 사과의 말씀을 드립니다.
결과는 이 페이지에서 보실 수 있습니다.
대회 문제는 조만간 AOJ에 업로드될 예정입니다. 문제가 다소간 어렵게 출제되었으나 반성과 정진의 기회 삼아 열심히 공부하시기 바랍니다.
다시 한 번 감사의 말씀을 드립니다.

10/28 10:35 - Practice Session


Practice session started!
Time : 2011. 10. 28. 20:00 ~ 22:00 (GMT+9, Seoul)
Problemset : http://libe.lavida.us/practice.pdf
Scoreboard : http://210.107.195.185/summary.html
Note that you can still register until 11:59am tomorrow.



10/28 02:35 - Connection Test


PC^2 server for the contest is running now. Please check whether you can login to the server.
( It's just a connectivity test, not the real contest. ).
You can download the PC^2 client program for the contest via this link : http://libe.lavida.us/pc2client.zip

Mails with the PC^2 accounts were sent for the teams who registered as of 2:22 am (GMT+9, Seoul).
Algospot admins have sent out a mail that contains your team's PC^2 account information.
You should be able to use this new account information to login our judge system. Note that this new account will be used for the actual contest.
The test accounts that were previously used to connect to our PC^2 server cannot and will not be used for the actual contest.
If your team did not received an email with new account information, please let us know by sending an email to algospot-admins@andromeda-express.com.
Best,



* 10/26 17:25 Registration of team '*_*' and 'Discrete 3rd grade' was rejected due to inaccurate registration information.
* 10/17 14:10 등록 양식을 불성실하게 기입한 VITAMIN 팀의 등록이 취소되었음을 알립니다.



Just like the last year, algospot.com proudly announces 2011 ACM-ICPC Daejeon Regional Warm-up Contest.
Please feel free to register. Thanks.

All of the problems and clarifications will be given in English.
전년과 같이 모든 문제와 질의 응답은 영어로 진행됩니다.

Contest Schedule


* 29th October (Sat.) 2:00 pm to 7:00 pm (See http://goo.gl/IaQSC to find out the time in your time zone)
* There will be a practice contest, and it will be announced later.

Eligibility


Anyone is welcomed, including foreigners.
Up to three people can construct a team to participate, and we recommend to do so.

Environment


We will use PC^2 for the contest system. The following compilers will be used:
* GNU C: gcc 4.5.2 (mingw)
* GNU C++: g++ 4.5.2 (mingw)
* Oracle Java: JDK 7 32-bit
* Microsoft C++: Visual C++ 2010

Registration


Please fill out the form in http://goo.gl/U94bu to register.
The list of registered teams - http://goo.gl/XGhvw - will be updated soon after your registration.
If you want to modify the registration record, please contact algospot-admins@andromeda-express.com.

Last Year's Problems


You may take a look on last year's problemset: http://algospot.com/contest/2010warmup/problems.pdf
There were two teams who solved nine problems each. You can judge your solution here in algospot (AOJ).


]]>
2010 인터넷 예선 I번 http://www.algospot.com/discussion/1265/2010-%EC%9D%B8%ED%84%B0%EB%84%B7-%EC%98%88%EC%84%A0-i%EB%B2%88- Mon, 19 Sep 2011 20:58:50 -0400 Sejoure 1265@/discussions 일단 2010년 인터넷 I번문제는
사람 N명이주어지고
M개의 데이터 혹은 질의가 들어오는데요
데이터에는 사람의 점수가 들어오고
질의가 나오면 그때까지 누적된 특정사람의 점수의 랭킹을 출력해야 하는 문제입니다.
저는 "실시간으로 소트되는거면 힙이나 인덱스드 트리"로 되겠지 해서 생각하다가 도저히 답이 안나와서
그냥 사람들의 각 점수를 2진수화 해서 그 2진수를 그대로 2진트리로 구현했습니다.
굳이 말씀드리자면 카운터소트를 하고 싶었는데 배열을 그만큼 못잡으니
각 점수의 이진수를 왼쪽 자식 오른쪽 자식으로 해서 단말에 각 점수의 데이터의 갯수를 넣었습니다.
그러면 랭크 세는것도 트리 뎁스만에 가능할거 같더군요.
각 점수의 누적합은 10^9을 넘지않으니, 2진 트리로 해도 뎁쓰가 30을 넘지 않으니,
30 * 200000정도여서 답은 나올 거 같은데요.

1. 아래 살펴보니 인덱스드 트리나, 균형잡힌 이진트리로 풀린다는데, 어떤식으로 푸는 방법일지 궁금합니다.
2. 혹시 힙에있는(그러니까, new나 malloc으로 잡은 메모리)를 한번에 없애는 방법이 있나요. 한 테스트 데이터가 끝난후 말끔히 없애고 싶은데.. 방법을 몰라서(이런 ㅠ; 기초적인걸 몰라서 ㅠㅠ)
3. 이건.. 그냥 대회에 대한 질문인데, 보통 테스트 케이스 하나당 1초정도 제한시간인가요.? 제한시간이 딱히 적혀있지 않아서]]>
인터넷 예선 문제 채점 데이터 http://www.algospot.com/discussion/1278/%EC%9D%B8%ED%84%B0%EB%84%B7-%EC%98%88%EC%84%A0-%EB%AC%B8%EC%A0%9C-%EC%B1%84%EC%A0%90-%EB%8D%B0%EC%9D%B4%ED%84%B0 Sat, 08 Oct 2011 11:23:14 -0400 전명우 1278@/discussions 채점 데이터는 원래 매년 공개를 안해왔었나요?]]> 2010 ACM-ICPC 서울대회 인터넷예선 D. 정육면체 문제 질문입니다 http://www.algospot.com/discussion/1277/2010-acm-icpc-%EC%84%9C%EC%9A%B8%EB%8C%80%ED%9A%8C-%EC%9D%B8%ED%84%B0%EB%84%B7%EC%98%88%EC%84%A0-d.-%EC%A0%95%EC%9C%A1%EB%A9%B4%EC%B2%B4-%EB%AC%B8%EC%A0%9C-%EC%A7%88%EB%AC%B8%EC%9E%85%EB%8B%88%EB%8B%A4 Sat, 08 Oct 2011 02:47:07 -0400 kki 1277@/discussions 지금 체점되나요? http://www.algospot.com/discussion/1276/%EC%A7%80%EA%B8%88-%EC%B2%B4%EC%A0%90%EB%90%98%EB%82%98%EC%9A%94 Fri, 30 Sep 2011 07:37:25 -0400 hiwaryi 1276@/discussions