728x90
반응형
#include <iostream>
#include <vector>
#include<map>
using namespace std;
int main()
{
ios::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int n;
cin >> n;
string s;
map<string, int>m;
for (int i = 0; i < n; i++) {
cin >> s;
m[s] = i;
}
vector<string>ans;
for (int i = 0; i < n; i++) {
cin >> s;
ans.push_back(s);
}
string p, q;
int cnt = 0;
for (int i = 0; i < n; i++) {
p = ans[i];
for (int j = i + 1; j < n; j++) {
q = ans[j];
if (m[p] < m[q])cnt++;
}
}
int amount = n * (n - 1) / 2;
cout << cnt << '/' << amount;
}
728x90
반응형
'하루 1문제 챌린지 > Silver3' 카테고리의 다른 글
백준 1448번 삼각형 만들기(C++) (0) | 2024.02.13 |
---|---|
백준 2503번 숫자야구 (C++) (0) | 2024.02.12 |
백준 15657번 N과 M(8) C++ (0) | 2024.01.31 |
백준 15655번 N과 M(6) C++ (0) | 2024.01.31 |
백준 N과 M(5) C++ (0) | 2024.01.31 |