码迷,mamicode.com
首页 > 其他好文 > 详细

2019 DISCS PrO High School Division

时间:2019-06-09 13:19:59      阅读:138      评论:0      收藏:0      [点我收藏+]

标签:dimens   space   spl   lan   const   tor   数学题   ack   struct   

A. Nate and Actual 3D Girls

技术图片
#include <bits/stdc++.h>
using namespace std;

const int maxn = 2e5 + 10;
int N, M, K;
string s, t;
map<char, int> mp;

int main() {
    scanf("%d%d%d", &N, &M, &K);
    K %= 26;
    while(N --) {
        cin >> s;
        for(int i = 0; s[i]; i ++)
            mp[s[i]] ++;
    }
    while(M --) {
        cin >> t;
        for(int i = 0; t[i]; i ++) {
            char c;
            int num = t[i] - a + 1;
            num += K;
            num %= 26;
            c = num + a - 1;
            mp[c] --;
        }
    }

    bool flag = true;
    for(int i = 0; i < 26; i ++)
        if(mp[i + a] < 0) flag = false;

    if(flag) printf("Make her kokoro go doki-doki!\n");
    else printf("It is gonna be daijoubu.\n");

    return 0;
}
View Code

B. Nate and Bones

技术图片
#include<bits/stdc++.h>
using namespace std;

int n, m, x;

int gcd(int a, int b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}

int main() {
  scanf("%d%d%d", &n, &m, &x);
  int ans = 0;
  for(int i = 1; i <= n * m; i ++) {
    int y;
    scanf("%d", &y);
    if(gcd(x, y) != 1) ans ++;
  }
  printf("%d\n", ans);
  return 0;
}
View Code

C. Nate and Contest Invitation

技术图片
#include <bits/stdc++.h>
using namespace std;

const int maxn = 1e5 + 10;
int N, M, K;
vector<int> v[maxn];
map<string, int> mp;
map<string, int> vis;
int see[maxn];
vector<int> ans;
int num = 0;

void dfs(int st) {
    see[st] = 1;

    for(int i = 0; i < v[st].size(); i ++) {
        if(see[v[st][i]] == 0) {
            dfs(v[st][i]);
            num ++;
        }
    }
}

int main() {
    scanf("%d%d%d", &N, &M, &K);
    mp.clear();
    vis.clear();
    memset(see, 0, sizeof(see));
    int cnt = 0;
    while(M --) {
        string st, en;
        cin >> st >> en;
        if(!vis[st]) {
            cnt ++;
            mp[st] = cnt;
            vis[st] = 1;
        }
        if(!vis[en]) {
            cnt ++;
            mp[en] = cnt;
            vis[en] = 1;
        }

        v[mp[st]].push_back(mp[en]);
        v[mp[en]].push_back(mp[st]);
    }

    for(int i = 1; i <= cnt; i ++) {
        if(see[i] == 0) {
            num = 1;
            dfs(i);
            ans.push_back(num);
        }
    }

    int sum = 0;
    int out = 0;
    for(int i = 0; i < ans.size(); i ++)
        sum += ans[i];

    sort(ans.rbegin(), ans.rend());

    if(sum == N) {
        K = min((int)ans.size(), K);
        for(int i = 0; i < K; i ++)
            out += ans[i];
    } else {
        if(K > (int)ans.size()) {
            out = sum + (K - (int)ans.size());
        } else {
            K = min((int)ans.size(), K);
            for(int i = 0; i < K; i ++)
                out += ans[i];
        }
    }

    printf("%d\n", min(N, out));

    return 0;
}
View Code

D. Nate and Dimension-Hopping Money

技术图片
#include<bits/stdc++.h>
using namespace std;

double a[10], x, y;

int main() {
  scanf("%lf%lf%lf", &a[1], &x, &y);

  a[2] = a[1] / (1 - (1 - x / 100) + (1 - y / 100) * (1 - x / 100));

  a[3] = (1 - x / 100) * a[2];

  a[4] = (1 - y / 100) * a[3];

  a[5] = a[4];

  printf("%.4f %.4f %.4f %.4f %.4f\n", a[1], a[2], a[3], a[4], a[5]);
  return 0;
}
View Code

F. Nate and Fan Meet-and-Greet

技术图片
#include <bits/stdc++.h>
using namespace std;

long long N;

int main() {
    scanf("%lld", &N);
    printf("%lld\n", N);
    return 0;
}
View Code

G. Nate and Game

技术图片
#include<bits/stdc++.h>
using namespace std;

const int maxn = 200000 + 10;
int n;
struct P {
  int L, R;
}s[maxn];

bool cmp(const P &a, const P &b) {
  return a.L < b.L;
}

int main() {
  scanf("%d", &n);
  for(int i = 1; i <= n; i ++) {
    int ymin = 2000000, ymax = -2000000;
    for(int j = 1; j <= 3; j ++) {
      int x, y;
      scanf("%d%d", &x, &y);
      ymin = min(ymin, y);
      ymax = max(ymax, y);
    }
    s[i].L = ymin;
    s[i].R = ymax;
  }

  sort(s + 1, s + n + 1, cmp);

  for(int i = 1; i <= n; i ++) {
  //  printf("[%d, %d]\n", s[i].L, s[i].R);
  }

  int ans = 0;
  int sz = 0;

  priority_queue<int> Q;

  int t = 1;

  for(int i = -1000000; i <= 1000000; i ++) {
    while(t <= n && s[t].L == i) {
      Q.push(-s[t].R);
      t ++;
      sz ++;
    }

    ans = max(ans, sz);

    while((!Q.empty()) && -1 * Q.top() == i) {
      Q.pop();
      sz --;
    }
  }

  ans = max(ans, sz);

  printf("%d\n", ans);

  return 0;
}
View Code

 

情侣局 ++

数学题专场???打扰了!

2019 DISCS PrO High School Division

标签:dimens   space   spl   lan   const   tor   数学题   ack   struct   

原文地址:https://www.cnblogs.com/zlrrrr/p/10993131.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!