A - League of Legends
答案
#include <iostream>
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define INF 0x3f3f3f3f3f3f3f3f
#define rep(i,a,b) for(auto i=a;i<=b;++i)
#define bep(i,a,b) for(auto i=a;i>=b;--i)
#define lowbit(x) x&(-x)
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define PI acos(-1)
#define pb push_back
#define eps 1e-6
const int mod = 1e9 + 7;
const int N = 1e6 + 10;
const int M = 211;
int dx[]={-1, 0, 1, 0};
int dy[]={0, 1, 0, -1};
using namespace std;
ll sum1=0;
ll sum2=0;
void solve(){
for(int i=1;i<=5;i++){
int x;
cin>>x;
sum1+=x;
}
for(int i=1;i<=5;i++){
int x;
cin>>x;
sum2+=x;
}
if(sum1<sum2) cout<<"Red"<<endl;
else cout<<"Blue"<<endl;
}
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
solve();
return 0;
}
C - Cube
答案
#include <iostream>
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define INF 0x3f3f3f3f3f3f3f3f
#define rep(i,a,b) for(auto i=a;i<=b;++i)
#define bep(i,a,b) for(auto i=a;i>=b;--i)
#define lowbit(x) x&(-x)
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define PI acos(-1)
#define pb push_back
#define eps 1e-4
const int mod = 1e9 + 7;
const int N = 1e6 + 10;
const int M = 211;
int dx[]={-1, 0, 1, 0};
int dy[]={0, 1, 0, -1};
using namespace std;
struct node{
int x,y,z;
}dp[N];
double len(int x1,int y1,int z1,int x2,int y2,int z2){
double ans=(x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)+(z1-z2)*(z1-z2);
ans=sqrt(ans);
return ans;
}
bool cmp(node x,node y){
if(x.x<y.x) return 1;
else if(x.x==y.x&&x.y<y.y) return 1;
else if(x.x==y.x&&x.y==y.y&&x.z<y.z) return 1;
return 0;
}
void solve(){
int t;
cin>>t;
while(t--){
vector<double>lens[11];
for(int i=1;i<=8;i++){
cin>>dp[i].x>>dp[i].y>>dp[i].z;
}
for(int i=1;i<=8;i++){
for(int j=1;j<=8;j++){
if(i!=j){
double l=len(dp[i].x,dp[i].y,dp[i].z,dp[j].x,dp[j].y,dp[j].z);
lens[i].pb(l);
}
}
sort(lens[i].begin(),lens[i].end());
}
bool flag=0;
for(int i=1;i<=8;i++){
for(int j=1;j<=8;j++){
if(i!=j){
for(int k=0;k<(int)lens[i].size();k++){
if(lens[i][k]!=lens[j][k]||!lens[i][k]){
flag=1;
break;
}
// cout<<" "<<lens[i][k]<<endl;
}
}
}
}
if(flag) cout<<"NO"<<endl;
else{
bool book=0;
if((lens[1][0]!=lens[1][1]||lens[1][0]!=lens[1][2]||lens[1][1]!=lens[1][2])) book=1;
if((lens[1][3]!=lens[1][4]||lens[1][3]!=lens[1][5]||lens[1][4]!=lens[1][5])) book=1;
if(!book) cout<<"YES"<<endl;
else cout<<"NO"<<endl;
}
}
}
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
solve();
return 0;
}
J - Grammy and Jewelry
答案
#include <iostream>
#include<bits/stdc++.h>
#define ll long long
#define mem(a,b) memset(a,b,sizeof a)
#define ull unsigned long long
#define INF 0x3f3f3f3f3f3f3f3f
#define rep(i,a,b) for(auto i=a;i<=b;++i)
#define bep(i,a,b) for(auto i=a;i>=b;--i)
#define lowbit(x) x&(-x)
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define PI acos(-1)
#define pb push_back
#define eps 1e-4
const int mod = 1e9 + 7;
const int N = 3e3 + 10;
const int M = 211;
int dx[]={-1, 0, 1, 0};
int dy[]={0, 1, 0, -1};
using namespace std;
ll n,m,t;
ll num[N];
ll mp[N][N];
ll dis[N];
bool vis[N];
ll val[N];
ll dp[N];
void BFS(ll x){
dis[x]=0;
vis[x]=1;
queue<ll>q;
q.push(x);
while(q.size()){
ll f=q.front();
q.pop();
for(ll i=1;i<=n;i++){
if(!vis[i]&&mp[f][i]){
dis[i]=dis[f]+1;
vis[i]=1;
q.push(i);
}
}
}
}
ll judge(ll x){
if(val[x]!=-1) return val[x];
ll res=0;
for(ll i=1;i<=x;i++){
res=max(res,judge(x-i)+dp[i]);
}
val[x]=res;
return res;
}
void solve(){
cin>>n>>m>>t;
mem(val,-1);
for(ll i=2;i<=n;i++) cin>>num[i];
num[1]=0;
while(m--){
ll u,v;
cin>>u>>v;
mp[u][v]=mp[v][u]=1;
}
BFS(1);
// cout<<"**"<<endl;
for(ll i=1;i<=n;i++){
dp[dis[i]]=max(dp[dis[i]],num[i]);
}
for(ll i=1;i<=t;i++){
if(i!=1) cout<<" ";
cout<<judge(i/2);
}
cout<<endl;
}
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
solve();
return 0;
}
L - String Freshman
答案
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
const int N = 100100;
typedef long long ll;
typedef pair<int, int> PII;
#define x first
#define y second
int n;
string s;
int nextt[N];
void get_next() {
int i = 0, j = -1;
nextt[0] = -1;
for (; i < n;) {
if (j == -1 || s[j] == s[i]) {
i++, j++;
nextt[i] = j;
} else {
j = nextt[j];
}
}
}
int main(int argc, char const *argv[]) {
cin >> n;
cin >> s;
get_next();
int flag = 0;
for (int i = 1; i <= n; i++) {
// cout << nextt[i] << " ";
if (nextt[i] != 0) {
flag = 1;
break;
}
}
if (flag == 0)
cout << "Correct" << endl;
else
cout << "Wrong Answer" << endl;
return 0;
}
M - Game Theory
答案
#include <iostream>
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define INF 0x3f3f3f3f3f3f3f3f
#define rep(i,a,b) for(auto i=a;i<=b;++i)
#define bep(i,a,b) for(auto i=a;i>=b;--i)
#define lowbit(x) x&(-x)
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define PI acos(-1)
#define pb push_back
#define eps 1e-4
const int mod = 1e9 + 7;
const int N = 1e6 + 10;
const int M = 211;
int dx[]={-1, 0, 1, 0};
int dy[]={0, 1, 0, -1};
using namespace std;
void solve(){
int n;
cin>>n;
// double ans=0;
// for(int i=1;i<=20;i++){
// for(int j=1;j<=20;j++){
// double x=(double)i;
// double y=(double)j;
// if(x>y) x+=10.0;
// else if(x<y) y+=10.0;
// ans+=(x-y)*1.0/400.0;
// }
// }
// n--;
// printf("%.4f\n",ans*n);
cout<<"0.0000"<<endl;
}
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
solve();
return 0;
}