forked from harrypotter0/algorithms-in-python
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ece5f55
commit 42bcc80
Showing
3 changed files
with
87 additions
and
0 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
for __ in range(int(input())): | ||
k = int(raw_input()) | ||
p = list() | ||
ne= list() | ||
n1 = list() | ||
for j in range(k): | ||
n1 = raw_input().split() | ||
s1 = raw_input() | ||
if s1=="yes": | ||
p.extend(n1) | ||
else: | ||
ne.extend(n1) | ||
# print(p) | ||
# print(ne) | ||
# | ||
# print(set(p)) | ||
# print(set(ne)) | ||
# print(set(p)-set(ne)) | ||
|
||
print(len(set(p)-set(ne))) | ||
# print(p) | ||
# print(ne) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
#include <bits/stdc++.h> | ||
#define ll long long int | ||
#define pb push_back | ||
#define ppb pop_back | ||
#define mp make_pair | ||
#define pii pair<int,int> | ||
#define vll vector<ll> | ||
#define vi vector<int> | ||
#define d0(x) cout<<x<<" " | ||
#define d1(x) cout<<x<<"\n" | ||
#define d2(x,y) cout<<x<<" "<<y<<"\n" | ||
#define d3(x,y,z) cout<<x<<" "<<y<<" "<<z<<"\n" | ||
#define d4(x,y,z,w) cout<<x<<" "<<y<<" "<<z<<" "<<w<<"\n" | ||
using namespace std; | ||
const ll mod=1e9+7; | ||
|
||
int main() | ||
{ | ||
//freopen("input.txt","r",stdin); | ||
ios_base::sync_with_stdio ( false ); | ||
int t;cin>>t; | ||
while(t--) | ||
{ | ||
int g,b;cin>>g>>b; | ||
string s[g][b];int score[g][b]; | ||
for(int i=0;i<g;i++) | ||
{ | ||
for(int j=0;j<b;j++) | ||
{ | ||
string k; | ||
cin>>s[i][j]>>k>>score[i][j]; | ||
} | ||
} | ||
string t1,t2;cin>>t1>>t2; | ||
int a1,b1,a2,b2; | ||
for(int i=0;i<g;i++) | ||
{ | ||
for(int j=0;j<b;j++) | ||
{ | ||
if(t1==s[i][j]){a1=i;b1=j;} | ||
if(t2==s[i][j]){a2=i;b2=j;} | ||
} | ||
} | ||
swap(s[a1][b1],s[a2][b2]); | ||
swap(score[a1][b1],score[a2][b2]); | ||
for(int i=0;i<g;i++) | ||
{ | ||
for(int j=0;j<b;j++) | ||
{ | ||
for(int k=0;k<b-1;k++) | ||
{ | ||
if(score[i][k]<score[i][k+1]) | ||
{ | ||
swap(score[i][k],score[i][k+1]); | ||
swap(s[i][k],s[i][k+1]); | ||
} | ||
} | ||
} | ||
} | ||
for(int i=0;i<g;i++) | ||
{ | ||
cout<<s[i][0]<<"\n"; | ||
} | ||
} | ||
} |