https://www.acmicpc.net/problem/1719 #include #include #include using namespace std;int main(){ int n,m; cin>>n>>m; int d[201][201]; int num[201][201]; const int INF = INT_MAX; for(int i=1; i>a>>b>>c; if(d[a][b] > c){ d[a][b] = c; d[b][a] = c; num[a][b] = b; num[b][a] = a; } } for(int k=1; k d[i][k] + d[k][j]){ ..
c++
https://www.acmicpc.net/problem/6137 #include #include using namespace std;int main(){ int n; cin>>n; string str = ""; string ans = ""; for(int i=0; i>c; str+=c; } int st = 0; int en = n - 1; while(st str[en]){ ans+=str[en]; str.erase(en, 1); en--; } else if(str[st] 어떤 문자열의 앞 / 뒤의 문자로 새로운 문자를 생성하는 것이므로 투포인터를..
https://www.acmicpc.net/problem/16120 #include #include using namespace std;int main(){ string str = ""; cin>>str; stack st; for(int i=0; i= 2 && str[i+1] == 'P' && i + 1 문자열에 들어 있는 "PPAP"를 다 "P"로 바꿔주고 남은 문자가 "P" 하나이면 PPAP를 출력하면 된다.만약 "P"라면 그대로 stack에 push한다.만약 "A"라면 이미 stack에 "P"가 두 개 이상 있는지, "A"의 다음 문자가 "P"인지 확인을 해서 맞다면원래 들어있던 "P" 두 개를 빼낸다.위에서 말한 케이스가 아니라면 무조건 PPAP가 아니므로 NP를 ..
https://school.programmers.co.kr/learn/courses/30/lessons/42898 프로그래머스코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.programmers.co.kr #include using namespace std;int solution(int m, int n, vector> puddles) { vector> dp(n + 1, vector(m + 1, 0)); vector> map(n + 1, vector(m + 1, 1)); for (auto p : puddles) { map[p[1]][p[0]] = 0; } ..