백준 1759 암호만들기 C++
[문제 링크]
https://www.acmicpc.net/problem/1759
[입출력 예]
입력 | 출력 |
---|---|
4 6 a t c i s w |
acis acit aciw acst acsw actw aist aisw aitw astw cist cisw citw istw |
[소스코드]
//11:57 #include <bits/stdc++.h> using namespace std; int L, C; char arr[15]; char res[15]; char v[15]; void func(int k){ if( k == L){ bool noVowel=true; int consonantCnt = 0; for (int i=0; i<L; i++) {if(res[i]=='a'||res[i]=='e'||res[i]=='i'||res[i]=='o'||res[i]=='u') noVowel=false; else consonantCnt++;} if(noVowel || consonantCnt<2)return; for(int i=0; i<L; i++)cout<<res[i]; cout<<'\n'; return; } for (int i= 0; i< C; i++){ if (k>0 && res[k-1]>arr[i]) continue; if (v[i]==0){ v[i]=1; res[k]=arr[i]; func(k+1); v[i]=0; } } } int main(){ ios::sync_with_stdio(0); cin.tie(0); cin>>L>>C; //L=4 C =6 for(int i= 0; i<C; i++) cin>>arr[i]; sort(arr,arr+C); func(0); return 0; }
'PS > BOJ' 카테고리의 다른 글
백준 1713 후보 추천하기 (0) | 2022.05.26 |
---|---|
백준 1062 가르침 파이썬 풀이 (0) | 2022.05.26 |
백준 1920 수 찾기 파이썬 (0) | 2022.02.18 |
BOJ 2580 스도쿠 C++ (0) | 2022.02.16 |
백준 1182 부분수열의 합 파이썬 풀이 (0) | 2022.02.12 |
댓글
이 글 공유하기
다른 글
-
백준 1713 후보 추천하기
백준 1713 후보 추천하기
2022.05.26정답코드 import sys input=sys.stdin.readline n=int(input()) student=int(input()) candidate={} for idx,i in enumerate(list(map(int,input().split()))): if i in candidate: candidate[i][2]+=1 else: if(len(candidate)==n): del candidate[sorted(list(candidate.values()),key=lambda x:(-x[2],-x[1]))[-1][0]] candidate[i]=[i,idx,1] print(' '.join(list(map(str,sorted(candidate.keys()))))) -
백준 1062 가르침 파이썬 풀이
백준 1062 가르침 파이썬 풀이
2022.05.26 -
백준 1920 수 찾기 파이썬
백준 1920 수 찾기 파이썬
2022.02.18[문제 링크] https://www.acmicpc.net/problem/1920 [입출력 예] 입력 출력 5 4 1 5 2 3 5 1 3 7 9 5 1 1 0 0 1 [소스코드] import sys input=sys.stdin.readline from collections import deque input() a=list(map(int,input().split())) input() test=list(map(int,input().split())) for i,x in enumerate(test): test[i]=[x,i,0] a.sort() test.sort() a=deque(a) test=deque(test) ans=[] while(a and test): cur_a=a.popleft() cur_test=t… -
BOJ 2580 스도쿠 C++
BOJ 2580 스도쿠 C++
2022.02.16[문제 링크] https://www.acmicpc.net/problem/2580 [입출력 예] 입력 출력 0 3 5 4 6 9 2 7 8 7 8 2 1 0 5 6 0 9 0 6 0 2 7 8 1 3 5 3 2 1 0 4 6 8 9 7 8 0 4 9 1 3 5 0 6 5 9 6 8 2 0 4 1 3 9 1 7 6 5 2 0 8 0 6 0 3 7 0 1 9 5 2 2 5 8 3 9 4 7 6 0 1 3 5 4 6 9 2 7 8 7 8 2 1 3 5 6 4 9 4 6 9 2 7 8 1 3 5 3 2 1 5 4 6 8 9 7 8 7 4 9 1 3 5 2 6 5 9 6 8 2 7 4 1 3 9 1 7 6 5 2 3 8 4 6 4 3 7 8 1 9 5 2 2 5 8 3 9 4 7 6 1 [소스코드] //14:54 …
댓글을 사용할 수 없습니다.