Codeforces Round #365 (Div. 2)

时间:2023-03-08 23:57:18
Codeforces Round #365 (Div. 2)

A题  Mishka and Game

水。。随便统计一下就A了

 #include <cstdio>
 #include <map>
 #include <set>
 #include <queue>
 #include <cstring>
 #include <algorithm>
 #include <iostream>
 #include <cmath>
 using namespace std;
 typedef long long LL;
 const int INF = 0x3f3f3f3f;
 #define mem0(x) memset(x,0,sizeof(x))
 #define mem1(x) memset(x,-1,sizeof(x))

 int main()
 {
     ,cnt2 = ;
     scanf("%d",&n);
     ; i < n; i++)
     {
         scanf("%d%d",&x,&y);
         if(x > y)
             cnt1++;
         else if(x < y)
             cnt2++;
     }
     if(cnt1 > cnt2)
         printf("Mishka\n");
     else if(cnt1 < cnt2)
         printf("Chris\n");
     else
         printf("Friendship is magic!^^\n");
     ;
 }

B题  Mishka and trip

题目大意:有n个城市,1-2-3-...-n-1连接,然后有k个首都,每个首都和每个城市都有一条路相连。但是,每两座城市直接最多只有一条路。每条路的权值,等于两个城市的魅力值乘积。问你所有路的权值之和是多少。

思路比较重要。这种类似的题型做过两三次了吧。

 #include <cstdio>
 #include <map>
 #include <set>
 #include <queue>
 #include <cstring>
 #include <algorithm>
 #include <iostream>
 #include <cmath>
 using namespace std;
 typedef long long LL;
 const int INF = 0x3f3f3f3f;
 #define mem0(x) memset(x,0,sizeof(x))
 #define mem1(x) memset(x,-1,sizeof(x))
  + ;
 int c[maxn], vis[maxn];
 int main()
 {
     mem0(vis);
     int n,k;
     scanf("%d%d",&n,&k);
     LL sum = , ans = ;
     ; i <= n; i++)
         scanf("%d",&c[i]), sum += c[i];

     ; i < k; i++)
     {
         int x;
         scanf("%d",&x);
         sum -= (LL)c[x];
         ans += (LL)c[x] * sum;
         vis[x] = ;
     }
     c[n+] = c[], vis[n+] = vis[];
     ; i <= n; i++)
     {
         ])
         ans += (LL)c[i] * c[i+];
     }
     printf("%lld\n",ans);

     ;
 }

C题  Chris and Road

这道题毫无头绪。。。

D题  Mishka and Interesting sum