-
Notifications
You must be signed in to change notification settings - Fork 10
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
70ccfd8
commit 8eae2c8
Showing
36 changed files
with
9,676 additions
and
0 deletions.
There are no files selected for viewing
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,55 @@ | ||
#include "bits/stdc++.h" | ||
using namespace std; | ||
|
||
# define s(n) scanf("%d",&n) | ||
# define sc(n) scanf("%c",&n) | ||
# define sl(n) scanf("%lld",&n) | ||
# define sf(n) scanf("%lf",&n) | ||
# define ss(n) scanf("%s",n) | ||
|
||
#define R(i,n) for(int i=0;i<(n);i++) | ||
#define FOR(i,a,b) for(int i=(a);i<=(b);i++) | ||
#define FORD(i,a,b) for(int i=(a);i>=(b);i--) | ||
|
||
# define INF (int)1e9 | ||
# define EPS 1e-9 | ||
# define MOD 1000000007 | ||
|
||
|
||
typedef long long ll; | ||
|
||
|
||
int main() | ||
{ | ||
int t=1; | ||
// cin >> t; | ||
while(t--){ | ||
int n; | ||
s(n); | ||
int a[n]; | ||
R(i,n){ | ||
s(a[i]); | ||
} | ||
ll sumlr[n+1],su=0; | ||
sumlr[0]=0; | ||
R(i,n){ | ||
su+=a[i]; | ||
sumlr[i+1]=su; | ||
} | ||
int ans=0; | ||
R(i,n){ | ||
for(int j=0;j<n-i;j++){ | ||
int summ=sumlr[j+i+1]-sumlr[j]; | ||
/*for(int k=j;k<=j+i;k++){ | ||
summ+=a[k]; | ||
}*/ | ||
ans^=summ; | ||
} | ||
} | ||
printf("%d\n",ans ); | ||
|
||
} | ||
|
||
return 0; | ||
} | ||
|
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,48 @@ | ||
#include "bits/stdc++.h" | ||
using namespace std; | ||
|
||
# define s(n) scanf("%d",&n) | ||
# define sc(n) scanf("%c",&n) | ||
# define sl(n) scanf("%lld",&n) | ||
# define sf(n) scanf("%lf",&n) | ||
# define ss(n) scanf("%s",n) | ||
|
||
#define R(i,n) for(int i=0;i<(n);i++) | ||
#define FOR(i,a,b) for(int i=(a);i<=(b);i++) | ||
#define FORD(i,a,b) for(int i=(a);i>=(b);i--) | ||
|
||
# define INF (int)1e9 | ||
# define EPS 1e-9 | ||
# define MOD 1000000007 | ||
|
||
|
||
typedef long long ll; | ||
|
||
int main() | ||
{ | ||
int t; | ||
cin >> t; | ||
while(t--){ | ||
int a,b; | ||
s(a);s(b); | ||
for(int i=1;;i++){ | ||
if(i%2==1){ | ||
a-=i; | ||
if(a<0){ | ||
printf("Bob\n"); | ||
break; | ||
} | ||
} | ||
else{ | ||
b-=i; | ||
if(b<0){ | ||
printf("Limak\n"); | ||
break; | ||
} | ||
} | ||
} | ||
} | ||
|
||
return 0; | ||
} | ||
|
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,64 @@ | ||
#include "bits/stdc++.h" | ||
using namespace std; | ||
|
||
# define s(n) scanf("%d",&n) | ||
# define sc(n) scanf("%c",&n) | ||
# define sl(n) scanf("%lld",&n) | ||
# define sf(n) scanf("%lf",&n) | ||
# define ss(n) scanf("%s",n) | ||
|
||
#define R(i,n) for(int i=0;i<(n);i++) | ||
#define FOR(i,a,b) for(int i=(a);i<=(b);i++) | ||
#define FORD(i,a,b) for(int i=(a);i>=(b);i--) | ||
|
||
# define INF (int)1e9 | ||
# define EPS 1e-9 | ||
# define MOD 1000000007 | ||
|
||
|
||
typedef long long ll; | ||
|
||
int main() | ||
{ | ||
int t; | ||
cin >> t; | ||
while(t--){ | ||
int n; | ||
ll k; | ||
s(n);sl(k); | ||
ll ans=0; | ||
string s; | ||
ll a[n]; | ||
int b[n]; | ||
fill_n(a,n,0); | ||
// fill_n(b,n,0); | ||
cin >> s; | ||
int a_count=0,b_count=0; | ||
R(i,n){ | ||
if(s[i]=='a'){ | ||
a_count++; | ||
} | ||
else if(s[i]=='b'){ | ||
b_count++; | ||
} | ||
a[i]=b_count; | ||
//b[i]=a_count; | ||
} | ||
R(i,n){ | ||
a[i]=b_count-a[i]; | ||
} | ||
/* R(i,n){ | ||
printf("%lld\n",a[i]); | ||
}*/ | ||
|
||
R(j,n){ | ||
if(s[j]=='a'){ | ||
ans+=b_count*(k*(k-1))/2 + k*a[j]; | ||
} | ||
} | ||
printf("%lld\n",ans ); | ||
} | ||
|
||
return 0; | ||
} | ||
|
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,112 @@ | ||
#include "bits/stdc++.h" | ||
using namespace std; | ||
|
||
# define s(n) scanf("%d",&n) | ||
# define sc(n) scanf("%c",&n) | ||
# define sl(n) scanf("%lld",&n) | ||
# define sf(n) scanf("%lf",&n) | ||
# define ss(n) scanf("%s",n) | ||
|
||
#define R(i,n) for(int i=0;i<(n);i++) | ||
#define FOR(i,a,b) for(int i=(a);i<=(b);i++) | ||
#define FORD(i,a,b) for(int i=(a);i>=(b);i--) | ||
|
||
# define INF (int)1e9 | ||
# define EPS 1e-9 | ||
# define MOD 1000000007 | ||
|
||
|
||
typedef long long ll; | ||
|
||
typedef struct { | ||
int x; | ||
int y; | ||
double dist; | ||
string s; | ||
}point; | ||
bool ComparePop (const point& l, const point& r) | ||
{ | ||
return l.dist < r.dist; | ||
} | ||
bool checkIng(string s,int kk){ | ||
R(i,kk){ | ||
if(s[i]=='0') | ||
return false; | ||
} | ||
return true; | ||
} | ||
int main() | ||
{ | ||
int t; | ||
cin >> t; | ||
while(t--){ | ||
int n,k; | ||
string temp; | ||
s(n);s(k); | ||
point shop[n]; | ||
R(i,n){ | ||
s(shop[i].x);s(shop[i].y); | ||
shop[i].dist=sqrt(shop[i].x*shop[i].x +shop[i].y*shop[i].y); | ||
} | ||
R(i,n){ | ||
cin >> shop[i].s; | ||
if(i==0){ | ||
temp=shop[i].s; | ||
} | ||
else{ | ||
R(j,k){ | ||
if(temp[j]=='0' && shop[i].s[j]=='1'){ | ||
temp[j]='1'; | ||
} | ||
} | ||
} | ||
} | ||
bool flag=true; | ||
// input com[...] | ||
printf("dsdsa\n"); | ||
R(j,k){ | ||
if(temp[j]=='0') | ||
{ | ||
printf("-1\n"); | ||
flag=false; | ||
break; | ||
} | ||
} | ||
if(flag){ | ||
sort(shop,shop+n,&ComparePop); | ||
string ans_string=""; | ||
double ans_dist=0; | ||
ans_string=shop[0].s; | ||
ans_dist+=shop[0].dist; | ||
int last_visit=0; | ||
int i; | ||
|
||
for(i=1;i<n;i++){ | ||
if(checkIng(ans_string,k)){ | ||
printf("%lf\n",ans_dist + shop[i-1].dist); | ||
break; | ||
}else{ | ||
bool goflag=false; | ||
R(j,k){ | ||
if(ans_string[j]=='0' && shop[i].s[j]=='1'){ | ||
ans_string[j]='1'; | ||
goflag=true; | ||
} | ||
} | ||
//cout << ans_string << endl; | ||
if(goflag){ | ||
last_visit=i; | ||
ans_dist+=sqrt((pow(shop[i].x-shop[i-1].x,2)) + (pow(shop[i].y-shop[i-1].y,2))); | ||
} | ||
} | ||
} | ||
if(i==n && checkIng(ans_string,k)){ | ||
printf("%lf\n",ans_dist + shop[last_visit | ||
].dist); | ||
} | ||
} | ||
} | ||
|
||
return 0; | ||
} | ||
|
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,48 @@ | ||
#include "bits/stdc++.h" | ||
using namespace std; | ||
|
||
# define s(n) scanf("%d",&n) | ||
# define sc(n) scanf("%c",&n) | ||
# define sl(n) scanf("%lld",&n) | ||
# define sf(n) scanf("%lf",&n) | ||
# define ss(n) scanf("%s",n) | ||
|
||
#define R(i,n) for(int i=0;i<(n);i++) | ||
#define FOR(i,a,b) for(int i=(a);i<=(b);i++) | ||
#define FORD(i,a,b) for(int i=(a);i>=(b);i--) | ||
|
||
# define INF (int)1e9 | ||
# define EPS 1e-9 | ||
# define MOD 1000000007 | ||
|
||
|
||
typedef long long ll; | ||
|
||
int main() | ||
{ | ||
int t; | ||
cin >> t; | ||
while(t--){ | ||
string s; | ||
cin >> s; | ||
int count1=0,count2=0; | ||
if(s[0]=='D') | ||
count1++; | ||
else | ||
count2++; | ||
for(int i=1;i<s.length();i++){ | ||
if(s[i-1]!='D' && s[i]=='D'){ | ||
count1++; | ||
} | ||
} | ||
for(int i=1;i<s.length();i++){ | ||
if(s[i-1]!='U' && s[i]=='U'){ | ||
count2++; | ||
} | ||
} | ||
printf("%d\n",count1 < count2 ? count1 : count2 ); | ||
} | ||
|
||
return 0; | ||
} | ||
|
Binary file not shown.
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,51 @@ | ||
#include "bits/stdc++.h" | ||
using namespace std; | ||
|
||
# define s(n) scanf("%d",&n) | ||
# define sc(n) scanf("%c",&n) | ||
# define sl(n) scanf("%lld",&n) | ||
# define sf(n) scanf("%lf",&n) | ||
# define ss(n) scanf("%s",n) | ||
|
||
#define R(i,n) for(int i=0;i<(n);i++) | ||
#define FOR(i,a,b) for(int i=(a);i<=(b);i++) | ||
#define FORD(i,a,b) for(int i=(a);i>=(b);i--) | ||
|
||
# define INF (int)1e9 | ||
# define EPS 1e-9 | ||
# define MOD 1000000007 | ||
|
||
|
||
typedef long long ll; | ||
|
||
int main() | ||
{ | ||
int t; | ||
cin >> t; | ||
int g; | ||
string s; | ||
while(t--){ | ||
int a[4]; // BEMR | ||
R(i,4){ | ||
cin >> s; | ||
s(g); | ||
switch(s[0]){ | ||
case 'B': a[0]=g;break; | ||
case 'E': a[1]=g;break; | ||
case 'M': a[2]=g;break; | ||
case 'R': a[3]=g;break; | ||
|
||
} | ||
} | ||
if(a[2]> a[3] && a[0]>a[1]){ | ||
printf("Barcelona\n"); | ||
} | ||
else{ | ||
printf("RealMadrid\n"); | ||
} | ||
|
||
} | ||
|
||
return 0; | ||
} | ||
|
Oops, something went wrong.