-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathC.cpp
63 lines (59 loc) · 1.89 KB
/
C.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
55
56
57
58
59
60
61
62
63
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
int main()
{
fastio;
int n,m,i,j,k;
char ara[200][200];
cin>>n>>m;
for(i=1;i<=2*n;i++)
{
for(j=1;j<=m;j++)
cin>>ara[i][j];
}
vector<pair <int,int> > vect;
for(i=0;i<2*n;i++)
vect.push_back( make_pair(0,i+1));
for(i=1;i<=m;i++)
{
for(j=0;j<n;j++)
{
if((ara[vect[2*j].second][i]=='G' && ara[vect[2*j+1].second][i]=='C') || (ara[vect[2*j].second][i]=='C' && ara[vect[2*j+1].second][i]=='P') || (ara[vect[2*j].second][i]=='P' && ara[vect[2*j+1].second][i]=='G'))
vect[2*j].first++;
else if((ara[vect[2*j+1].second][i]=='G' && ara[vect[2*j].second][i]=='C') || (ara[vect[2*j+1].second][i]=='C' && ara[vect[2*j].second][i]=='P') || (ara[vect[2*j+1].second][i]=='P' && ara[vect[2*j].second][i]=='G'))
vect[2*j+1].first++;
}
for(k=0;k<2*n;k++)
{
for(j=k+1;j<2*n;j++)
{
if(vect[k].first<vect[j].first)
{
int temp=vect[k].second;
vect[k].second=vect[j].second;
vect[j].second=temp;
temp=vect[k].first;
vect[k].first=vect[j].first;
vect[j].first=temp;
}
}
}
//sort(vect.begin(),vect.end());
for(k=0; k<2*n; k++)
{
for(j=k+1; j<2*n; j++)
{
if((vect[k].first==vect[j].first) && (vect[j].second<vect[k].second))
{
int temp=vect[k].second;
vect[k].second=vect[j].second;
vect[j].second=temp;
}
}
}
}
for(i=0;i<2*n;i++)
cout<<vect[i].second<<"\n";
return 0;
}