• codeforces #586 ABC~D


    A. Cards

    Description

    给定一个仅由onezr组成的字符串,one-1,zero-0。

    问能组成的最大的数值是多少。

    Solution

    模拟贪心。

    B. Multiplication Table

    Description

    给定一个$n imes n$的矩阵m,其主对角线上元素为0。

    求一个a向量使得$a[i] imes a[j] = m[i][j] ,i !=j$。

    Solution

    $a[i] imes a[j] =m[i][j],a[i] imes a[k] = m[i][k] a[j] imes a[k] = m[j][k] ightarrow a[i]^2=frac{m[i][j] imes m[i][k]}{m[j][k]}$

    C. Substring Game in the Lesson

    Description

    Solution

    显然r不能增大。

    那么只要左边存在一个子串字典序小于s[k],那么Ann跳到最左一个即可。

      1 #include <algorithm>
      2 #include <cctype>
      3 #include <cmath>
      4 #include <cstdio>
      5 #include <cstdlib>
      6 #include <cstring>
      7 #include <iostream>
      8 #include <map>
      9 #include <numeric>
     10 #include <queue>
     11 #include <set>
     12 #include <stack>
     13 #if __cplusplus >= 201103L
     14 #include <unordered_map>
     15 #include <unordered_set>
     16 #endif
     17 #include <vector>
     18 #define lson rt << 1, l, mid
     19 #define rson rt << 1 | 1, mid + 1, r
     20 #define LONG_LONG_MAX 9223372036854775807LL
     21 #define pblank putchar(' ')
     22 #define ll LL
     23 #define fastIO ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
     24 using namespace std;
     25 typedef long long ll;
     26 typedef long double ld;
     27 typedef unsigned long long ull;
     28 typedef pair<int, int> P;
     29 int n, m, k;
     30 const int maxn = 5e5 + 10;
     31 template <class T>
     32 inline T read()
     33 {
     34     int f = 1;
     35     T ret = 0;
     36     char ch = getchar();
     37     while (!isdigit(ch))
     38     {
     39         if (ch == '-')
     40             f = -1;
     41         ch = getchar();
     42     }
     43     while (isdigit(ch))
     44     {
     45         ret = (ret << 1) + (ret << 3) + ch - '0';
     46         ch = getchar();
     47     }
     48     ret *= f;
     49     return ret;
     50 }
     51 template <class T>
     52 inline void write(T n)
     53 {
     54     if (n < 0)
     55     {
     56         putchar('-');
     57         n = -n;
     58     }
     59     if (n >= 10)
     60     {
     61         write(n / 10);
     62     }
     63     putchar(n % 10 + '0');
     64 }
     65 template <class T>
     66 inline void writeln(const T &n)
     67 {
     68     write(n);
     69     puts("");
     70 }
     71 template <typename T>
     72 void _write(const T &t)
     73 {
     74     write(t);
     75 }
     76 template <typename T, typename... Args>
     77 void _write(const T &t, Args... args)
     78 {
     79     write(t), pblank;
     80     _write(args...);
     81 }
     82 template <typename T, typename... Args>
     83 inline void write_line(const T &t, const Args &... data)
     84 {
     85     _write(t, data...);
     86 }
     87 char s[maxn];
     88 int pre[maxn], tmp[maxn];
     89 int main(int argc, char const *argv[])
     90 {
     91 #ifndef ONLINE_JUDGE
     92     freopen("in.txt", "r", stdin);
     93     // freopen("out.txt", "w", stdout);
     94 #endif
     95     fastIO;
     96     cin >> s + 1;
     97     n = strlen(s + 1);
     98     tmp[0] = 1e9;
     99     for (int i = 1; i <= n; i++)
    100         tmp[i] = min(tmp[i - 1], (int)s[i]);
    101     for (int i = 1; i <= n; i++)
    102     {
    103         int f = tmp[i] >= s[i];
    104         if (f)
    105             puts("Mike");
    106         else
    107             puts("Ann");
    108     }
    109     return 0;
    110 }
    View Code

    D. Alex and Julian

    Description

    给定一个数字集合S。

    当集合内元素满足$|i-j| in S$时,i向j连一条无向边。

    求删除最少的数字使集合内剩余的数构成一个二分图(不存在奇环)

    Solution

    不是很懂还,再想想。

      1 #include <algorithm>
      2 #include <cctype>
      3 #include <cmath>
      4 #include <cstdio>
      5 #include <cstdlib>
      6 #include <cstring>
      7 #include <iostream>
      8 #include <map>
      9 #include <numeric>
     10 #include <queue>
     11 #include <set>
     12 #include <stack>
     13 #if __cplusplus >= 201103L
     14 #include <unordered_map>
     15 #include <unordered_set>
     16 #endif
     17 #include <vector>
     18 #define lson rt << 1, l, mid
     19 #define rson rt << 1 | 1, mid + 1, r
     20 #define LONG_LONG_MAX 9223372036854775807LL
     21 #define pblank putchar(' ')
     22 #define ll LL
     23 #define fastIO ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
     24 using namespace std;
     25 typedef long long ll;
     26 typedef long double ld;
     27 typedef unsigned long long ull;
     28 typedef pair<int, int> P;
     29 int n, m, k;
     30 const int maxn = 2e5 + 10;
     31 template <class T>
     32 inline T read()
     33 {
     34     int f = 1;
     35     T ret = 0;
     36     char ch = getchar();
     37     while (!isdigit(ch))
     38     {
     39         if (ch == '-')
     40             f = -1;
     41         ch = getchar();
     42     }
     43     while (isdigit(ch))
     44     {
     45         ret = (ret << 1) + (ret << 3) + ch - '0';
     46         ch = getchar();
     47     }
     48     ret *= f;
     49     return ret;
     50 }
     51 template <class T>
     52 inline void write(T n)
     53 {
     54     if (n < 0)
     55     {
     56         putchar('-');
     57         n = -n;
     58     }
     59     if (n >= 10)
     60     {
     61         write(n / 10);
     62     }
     63     putchar(n % 10 + '0');
     64 }
     65 template <class T>
     66 inline void writeln(const T &n)
     67 {
     68     write(n);
     69     puts("");
     70 }
     71 template <typename T>
     72 void _write(const T &t)
     73 {
     74     write(t);
     75 }
     76 template <typename T, typename... Args>
     77 void _write(const T &t, Args... args)
     78 {
     79     write(t), pblank;
     80     _write(args...);
     81 }
     82 template <typename T, typename... Args>
     83 inline void write_line(const T &t, const Args &... data)
     84 {
     85     _write(t, data...);
     86 }
     87 ll a[maxn];
     88 vector<int> g[65];
     89 int main(int argc, char const *argv[])
     90 {
     91 #ifndef ONLINE_JUDGE
     92     freopen("in.txt", "r", stdin);
     93     // freopen("out.txt", "w", stdout);
     94 #endif
     95     n = read<int>();
     96     for (int i = 1; i <= n; i++)
     97     {
     98         ll x = read<ll>();
     99         k = 0;
    100         while (x % 2 == 0)
    101         {
    102             ++k;
    103             x /= 2;
    104         }
    105         g[k].emplace_back(i);
    106     }
    107     int maxx = 0, f = -1;
    108     for (int i = 0; i < 64; i++)
    109         if (g[i].size() > maxx)
    110             maxx = g[i].size(), f = i;
    111     int res = 0;
    112     for (int i = 0; i < 64; i++)
    113         if (i != f)
    114             res += g[i].size();
    115     writeln(res);
    116     for (int i = 0; i < 64; i++)
    117         if (i != f)
    118             for (int j = 0; j < g[i].size(); j++)
    119                 write(g[i][j]), pblank;
    120     return 0;
    121 }
    View Code
  • 相关阅读:
    elk
    WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! 解决方法
    openssh 升级到8.2版本 (Linux 7)
    Linux 结合grep kill掉指定字符进程
    mysql 主从由于事务性挂断执行语句
    plsql 安装
    linux 7 本地化安装docker (阿里云版)
    docker 配置加速器
    Oracle 归档日志
    多线程事件
  • 原文地址:https://www.cnblogs.com/mooleetzi/p/11827868.html
Copyright © 2020-2023  润新知