forked from Prince-1501/Hello_world-Competiitve-Programming
-
Notifications
You must be signed in to change notification settings - Fork 1
/
43_codechef_attendance.cpp
60 lines (47 loc) · 1.04 KB
/
43_codechef_attendance.cpp
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
//
// main.cpp
// CODE-CHEF
//
// Created by Prince Kumar on 18/05/19.
// Copyright © 2019 Prince Kumar. All rights reserved.
//
// ------- ** Attendance ** --------- //
#include <iostream>
using namespace std;
int main()
{
int T;cin>>T;
while(T--)
{
int n; cin>>n;
string f[n];
string l[n];
for(int i=0;i<n;i++)
{
cin>>f[i]>>l[i]; // first name and last name
}
int a[n];
for(int i=0;i<n;i++){a[i]=0;}
// initalise the array - a --> to 0
for(int i=0;i<n-1;i++)
{
for(int j=i+1;j<n;j++)
{
if(f[i]==f[j])
{a[i]++; a[j]++;}
}
}
// we check the condition on array a
for(int i=0;i<n;i++)
{
if(a[i]==0)
{
cout<<f[i]<<endl;
}
else
{
cout<<f[i]<<" "<<l[i]<<endl;
}
}
}
}