using namespace std;
int main() {
int t;
cin >> t;
for (int j = 0; j < t; j++) {
int n;
cin >> n;
vector<string> cities;
for (int i = 0; i < n; i++) {
cin >> cities[i];
}
int size = cities.size();
for (int i = 0; i < n; i++) {
for (int k = 1; k < n; k++) {
if (cities[i] == cities[k]) size--;
}
}
cout << size << '
';
}
}
So, this task is from kattis website(link: https://open.kattis.com/problems/everywhere) and the goal is to get the number of the cities someone has visited, the problem is that some of these cities were visited twice or even more, so the only thing we need is to get the number of cities.
That's how input looks like:
7
saskatoon
toronto
winnipeg
toronto
vancouver
saskatoon
toronto
3
edmonton
edmonton
edmonton
And my code doesn't let me input the whole input, I mean, I input 3 values and then program stops working. Can you help me?
question from:
https://stackoverflow.com/questions/65645753/my-c-code-does-not-let-me-input-all-input-values-and-i-dont-know-why 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…