알고스팟(algospot.com) 기초문제 풀이답안
stl map의 key 찾는 법과, loop 참고용
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 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | #include <iostream> #include <sstream> #include <map> using namespace std; int main() { int cnt; cin >> cnt; stringstream output; while (cnt--) { map< int , int > xcount, ycount; for ( int i = 0; i < 3; i++) { int x, y; cin >> x; cin >> y; if (xcount.find(x) == xcount.end()) xcount[x] = 1; else xcount[x]++; if (ycount.find(y) == ycount.end()) ycount[y] = 1; else ycount[y]++; } for (auto iter : xcount) { if (iter.second == 1) output << iter.first; } output << " " ; for (auto iter : ycount) { if (iter.second == 1) output << iter.first; } output << endl; } cout << output.str(); return 0; } |
'C++ > 알고리즘' 카테고리의 다른 글
[마이다스챌린지2017예선] 트럼프카드 문제 (TrumpCard) (0) | 2017.05.14 |
---|---|
[마이다스챌린지2017예선] 소수합 문제 (0) | 2017.05.13 |
[마이다스챌린지2017예선] 마이다스수(소수구하기) (0) | 2017.05.13 |
[마이다스챌린지2017예선] 세일이벤트 문제 (0) | 2017.05.13 |
[알고스팟] string split and sort (0) | 2017.05.13 |