티스토리 뷰
r,f 좌표를 통해 고객이 어디에 해당하는지 분류하는 문제다.
r은 현재시간 - 가장 최근 접속시간
f는 유저의 접속 횟수다
맵을 이용해서 <name,<최근접속시간,접속 횟수>> 를 저장하면 문제를 풀 수있다!
근데 소스가 더럽다!
처음에 틀렸는데 다음 코드를 추가하니 맞았다.
cin이 느려서 그런가보다
ios::sync_with_stdio(false);
cin.tie(0);
소스코드
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 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 | #include <iostream> #include <algorithm> #include <string> #include <set> #include <map> using namespace std; string name; int n; set<double> rs, fs; map<string, pair<double, double>> mp; double r[4], f[4]; void print(double x, double y) { if (rs.count(x) || fs.count(y)) { print(x - 0.5, y - 0.5); return; } if (x < r[0]) { if (y < f[0]) puts("New Customer"); else if (y < f[1]) puts("Potential Loyalist"); else if (y < f[2]) puts("Potential Loyalist"); else if (y < f[3]) puts("Loyal Customer"); else puts("Champion"); } else if (x < r[1]) { if (y < f[0]) puts("Promising"); else if (y < f[1]) puts("Potential Loyalist"); else if (y < f[2]) puts("Potential Loyalist"); else if (y < f[3]) puts("Loyal Customer"); else puts("Loyal Customer"); } else if (x < r[2]) { if (y < f[0]) puts("About to Sleep"); else if (y < f[1]) puts("About to Sleep"); else if (y < f[2]) puts("Need Attention"); else if (y < f[3]) puts("Loyal Customer"); else puts("Loyal Customer"); } else if (x < r[3]) { if (y < f[0]) puts("Lost"); else if (y < f[1]) puts("Hibernating"); else if (y < f[2]) puts("About to Leave"); else if (y < f[3]) puts("About to Leave"); else puts("About to Leave"); } else { if (y < f[0]) puts("Lost"); else if (y < f[1]) puts("Lost"); else if (y < f[2]) puts("About to Leave"); else if (y < f[3]) puts("About to Leave"); else puts("Can't Lose Them"); } } int main() { ios::sync_with_stdio(false); cin.tie(0); for (int i = 0; i < 4; i++)cin>>r[i], rs.insert(r[i]); for (int i = 0; i < 4; i++)cin>>f[i], fs.insert(f[i]); cin >> n; int x; for (int i = 1; i <= n; i++) { cin >> x; cin >> name; if (x == 1) { mp[name].first = i; if (mp.count(name)) mp[name].second += 1; else mp[name].second = 1; } else { if (mp.count(name)) { double r = (double)i - mp[name].first; double f = mp[name].second; print(r, f); } else puts("None"); } } } | cs |
'알고리즘 > BOJ' 카테고리의 다른 글
[백준] 7578 공장 (0) | 2018.05.30 |
---|---|
[백준] 15805 트리 나라 관광 가이드 (0) | 2018.05.29 |
[백준] 15803 PLAYERJINAH’S BOTTLEGROUNDS (0) | 2018.05.29 |
[백준] 15783 세진 바이러스 (0) | 2018.05.28 |
[백준] 14585 사수빈탕 (0) | 2018.05.17 |
댓글