var t,n,m,i,j,a,b:word;s:string;beginreadln(t);j:=0;repeatreadln(n);readln(s);j+=1;m:=length(s)-4;a:=0;b:=0;i:=1;while i 풀이 's', 'h', 'e', 'e', 'p', ' ' 또는 's', 'h', 'e', 'e', 'p', \0 의 개수를 구하는 문제입니다. b 가 0 이면, 특정 단어가 찾고자 하는 건지 판단합니다!아니라면 b=1로 바꾸고 새로운 단어가 온다는 것을 알려주는 ' ' (공백, blank) 문자가 올때까지 i 을 1씩 증가시킵니다.' '을 만나면 다시 b=0으로 바꾼다음 새로운 문자가 찾고자 하는게 맞는지 판단합니다. 주의 할 점 : 띄어쓰기 2줄!!!, sheepsheep 이건 shee..
var n,i:word;a,d:array[0..999]of word;beginread(n);for i:=0 to 999 do d[i]:=0; for i:=1 to n do begin read(a[i]);d[a[i]]+=1;end;for i:=1 to 999 do d[i]+=d[i-1];for i:=1 to n do writeln(1+d[a[i]-1]);end. 먼저 들어온대로 순서를 매기는 문제입니다.단 동시에 들어온 경우 (ex 1등 2명, 2등 1명)2등은 존재하지 않으며 3등이 됩니다. 풀이1. 배열 a는 입력받은 수를 순서대로 저장, 배열 d는 1~1000 수가 얼마나 입력됬는지를 저장2. d[i] += d[i-1] 을 반복합니다 (누적합), 이것을 해야 자신 앞에 얼마나 많이 있는지 확인이 가능..

var a,b,c,d:int64;begind:=0;read(a,b,c);if (c mod 2)=1 then c-=1;if b=0 then d:=3*c div 2else if c>1 then begin d:=(b-1)*2+5; d+=3*(c-2)div 2;end;if a>0 then d+=a*2;write(d);end. 풀이 1. Corner 블럭 짝수개를 취합니다.2. S-tile 은 Corner 블럭이 2개가 있다면 연결할 수 있습니다. 중요한것은 Corner 블럭 2개가 있다면 반드시 그 사이에 S-tile 블럭을 끼어넣는것이 좋습니다.또한 S-tile 끼리 서로 연결한 다음 양 끝쪽에 Corner을 붙이면 됩니다. (S-tile - 1)*2 + 5 만큼 증가시켜줍니다.만약 짝수개의 Corner ..

var n,m,a,b,i:int64;v:array[1..200000]of byte;beginreadln(n,m);for i:=2 to n do v[i]:=0;v[1]:=1;for i:=1 to m do beginreadln(a,b);if a>b then v[a]:=1 else v[b]:=1;end;for i:=2 to n do if v[i]=0 then begin v[1]:=0;break;end;if v[1]=0 then write('NO')else write('YES');end.풀이 : 그래프 https://www.acmicpc.net/problem/33706 만약 1-2-4-3 이라는 그래프가 있다면 위의 조건을 만족하지 않습니다. (1에서 3으로 가는 것보다 1에서 4로 갈때의 가중치가 반드시 작..
var n,m,i,j,k,f,p:int64;a:array[1..2000]of string;x,y,z:string;beginp:=1;a[1]:='ChongChong';readln(n);for i:=1 to n do beginreadln(z); //문자열 두개 입력받기m:=length(z);f:=0;x:='';y:='';for j:=1 to m do begin //문자열을 공백기준으로 두개로 나누기if z[j]=' ' then begin f:=1;endelse begin if f=0 then x+=z[j] else y+=z[j];end;end;f:=0;k:=0;for j:=1 to p do begin //춤을 추는 사람이 있는지 확인 if x=a[j] then f+=1; if y=a[j] then k+=1;..

var n,m,i,j,x,g:int64;a:array[0..9999]of integer;beginreadln(n,m); //입력g:=n div 2;n-=1; //shell sort 준비for i:=0 to n do read(a[i]); //책들의 위치들을 배열로 입력받음while 1=1 do begin //shell sort : 오름차순 정렬if (g mod 2)=0 then g+=1;for i:=g to n do beginj:=i-g;x:=a[i];while j>=0 do beginif a[j]>x then a[j+g]:=a[j] else break;j-=g;end;a[j+g]:=x;end;if g=1 then break;g:= g div 2;end;x:=0;n+=1;i:=0; //음수값부터 이동거리 ..
var n,i,j,k,g,x,y,w:int64;a,b:array[0..49]of int64;s:array[0..49]of string;z:string;beginreadln(n);n-=1;for i:=0 to n do readln(s[i]); //문자열 n개 입력 받고 문자열 배열에 저장for i:=0 to n do begin //문자열 한개씩 길이와, 숫자의 합을 구해줌 a[i]:=length(s[i]); //길이 b[i]:=0; //숫자의 합을 담을 배열을 초기화 for j:=1 to a[i] do if (s[i][j]>='0') and (s[i][j]=0 do beginw:=0;if a[j]>x then w:=1 //앞에 있는 것이 더 길이가 길다면else if a[j]=x then begin //..

var x1,x2,x3,x4,y1,y2,y3,y4,w,h,a:int64;begina:=0;readln(x1,y1,x2,y2);readln(x3,y3,x4,y4);read(w,h);if (x2-x1>=w) then begin if (y3-y1>=h) or (y2-y4>=h) then a:=1;end;if (y2-y1>=h) then begin if (x3-x1>=w) or (x2-x4>=w) then a:=1;end;if a=0 then write('No') else write('Yes');end. 풀이 : 기하학 Graveyard 내부에 Chapel 이 있으며, 우리는 Graveyard 내부에서 Chapel의 영역을 침범하지 않은채 Grave을 추가할 수 있는지를 알아보아야 합니다. 두가지 방향에서 바..

var a,b,c,d,e,f,m,x,y:int64;beginx:=0;readln(a,b);readln(c,d);read(e,f);//0번 : 세개를 나열if(a=c) and (a=e) and (a=b+d+f) then x:=1;if(a=c) and (a=f) and (a=b+d+e) then x:=1;if(a=d) and (a=e) and (a=b+c+f) then x:=1;if(a=d) and (a=f) and (a=b+c+e) then x:=1;if(b=c) and (b=e) and (b=a+d+f) then x:=1;if(b=c) and (b=f) and (b=a+d+e) then x:=1;if(b=d) and (b=e) and (b=a+c+f) then x:=1;if(b=d) and (b=f) a..
- Total
- Today
- Yesterday
- 스택
- 구현
- 문자열
- 덱
- 1835번
- 누적합
- Krustal
- 백준
- DP
- XOR
- java
- Segment Tree
- 그리디
- 오프라인 쿼리
- Lazy Propagation
- C언어
- PASCAL
- 1835
- find
- 브루트포스
- DFS
- 정렬
- C++
- 최소 스패닝 트리
- union
- BFS
- 그래프
- 누적 합
- 기하학
- 세그먼트 트리
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | |||||
3 | 4 | 5 | 6 | 7 | 8 | 9 |
10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 20 | 21 | 22 | 23 |
24 | 25 | 26 | 27 | 28 | 29 | 30 |
31 |