• codeforces--283--


    这场比以往的难点额= =

    A题就是 每次删掉2-N-1这(N-2)位置上的一个元素 然后观察 max(a[i]-a[i-1])。

     1 #include <iostream>
     2 #include <algorithm>
     3 using namespace std;
     4 
     5 int a[110];
     6 
     7 int main()
     8 {
     9     int n , ans , sum;
    10     sum = 11111111;
    11     ans = 0;
    12     cin >> n;
    13     cin >> a[1];
    14     for( int i = 2 ; i<=n ; i++ )
    15     {
    16         cin >> a[i];
    17         ans = max( ans , a[i]-a[i-1] );
    18     }
    19     for( int i = 2 ; i<=n-1 ; i++ )
    20     {
    21         sum = min( sum , a[i+1] - a[i-1] );
    22     }
    23     cout << max(sum,ans) << endl;
    24     return 0;
    25 }
    View Code

    B题 add操作最多执行10次 每一次操作完成之后 再对整个字符串进行 循环移位

     1 #include <iostream>
     2 #include <string>
     3 using namespace std;
     4 
     5 string ans , str;
     6 
     7 void solve( )
     8 {
     9     string s , t;
    10     char ch;
    11     int len = str.length();
    12     int temp;
    13     for( int T = 1 ; T<=10 ; T++ )
    14     {
    15         s = "";
    16         for( int i = 0 ; i<len ; i++ )
    17         {
    18             temp = (str[i]-'0'+T)%10;//char转int
    19             ch = temp + '0';//int转char
    20             s += ch;
    21         }
    22         if( s<ans )
    23             ans = s;
    24         for( int j = 1 ; j<len ; j++ )
    25         {
    26             t = "";
    27             t.append(s,j,len-j);
    28             t.append(s,0,j);
    29             if( t<ans )
    30                 ans = t;
    31         }
    32     }
    33 }
    34 
    35 int main()
    36 {
    37     int n;
    38     cin >> n;
    39     cin >> str;
    40     ans = str;
    41     solve( );  
    42     cout << ans << endl;
    43 }
    View Code

    C题 每次只能删除一列上的所有元素 字典序的排列是对行进行要求的 所以暴力遍历过去就好 注意标记 

     1 #include <iostream>
     2 #include <cstring>
     3 using namespace std;
     4 
     5 int n , m , cnt;
     6 const int size = 110;
     7 char str[size][size];
     8 bool can[size];
     9 
    10 void solve()
    11 {
    12     bool flag;
    13     cnt = 0;
    14     memset( can , false , sizeof(can) );
    15     for( int i = 0 ; i<m ; i++ )
    16     {
    17         flag = true;
    18         for( int j = 0 ; j<n-1 ; j++ )
    19         {
    20             if( !can[j] && str[j][i] > str[j+1][i] )
    21             {
    22                 ++ cnt;
    23                 flag = false;
    24                 break;
    25             }
    26         }
    27         if( flag )
    28         {
    29             for( int j = 0 ; j<n-1 ; j++ )
    30             {
    31                 if( str[j][i] < str[j+1][i] )
    32                 {
    33                     can[j] = true;    
    34                 }
    35             }
    36         }
    37     }
    38 }
    39 
    40 int main()
    41 {
    42     cin >> n >> m;
    43     for( int i = 0 ; i<n ; i++ )
    44     {
    45         cin >> str[i];
    46     }
    47     solve();
    48     cout << cnt << endl;
    49     return 0;
    50 }
    View Code

    D题  porker说是个大模拟 我不会= =

     1 #include <iostream>
     2 #include <algorithm>
     3 #include <cstring>
     4 using namespace std;
     5 
     6 class data {
     7 public:
     8     int s, t;
     9     bool operator<(const data& p) const {
    10         if (s < p.s) return true;
    11         else if (s == p.s && t < p.t) return true;
    12         else return false;
    13     }
    14 };
    15 
    16 int sum[2][100100];
    17 data ans[100100];
    18 int counts;
    19 
    20 int main() {
    21     int n;
    22     cin.sync_with_stdio(false);
    23     cin >> n;
    24     sum[0][0] = sum[0][1] = 0;
    25     for (int i = 1; i <= n; i++) {
    26         int d;
    27         cin >> d;
    28         d--;
    29         sum[0][i] = sum[0][i - 1];
    30         sum[1][i] = sum[1][i - 1];
    31         sum[d][i]++;
    32     }
    33     counts = 0;
    34     int maximum = max(sum[0][n], sum[1][n]);
    35     for (int i = 1; i <= maximum; i++) {
    36         int sets[2] = { 0, 0 };
    37         int index = 0;
    38         int interval = i * 2;
    39         bool flag = true;
    40         int lastwin = -1;
    41         while (index < n) {
    42             int nextindex = index + interval;
    43             int maxindex = index + interval;
    44             if (maxindex > n + 1) {
    45                 maxindex = n + 1;
    46             }
    47             int first_index = lower_bound(sum[0] + index + 1, sum[0] + maxindex, sum[0][index] + i) - sum[0];
    48             int second_index = lower_bound(sum[1] + index + 1, sum[1] + maxindex, sum[1][index] + i) - sum[1];
    49             if (first_index < second_index) {
    50                 sets[0]++;
    51                 lastwin = 0;
    52             }
    53             else if (second_index < first_index) {
    54                 sets[1]++;
    55                 lastwin = 1;
    56             }
    57             else {
    58                 flag = false;
    59             }
    60             index = min(first_index, second_index);
    61         }
    62         if (!flag) continue;
    63         if (sets[0] > sets[1] && lastwin == 0 || sets[0] < sets[1] && lastwin == 1) {
    64             ans[counts].s = max(sets[0], sets[1]);
    65             ans[counts].t = i;
    66             counts++;
    67         }
    68     }
    69     sort(ans, ans + counts);
    70     cout << counts << endl;
    71     for (int i = 0; i < counts; i++) {
    72         cout << ans[i].s << " " << ans[i].t << endl;
    73     }
    74     //    system("pause");
    75 }
    View Code
  • 相关阅读:
    Java+seleinum+testng框架UI自动化测试环境搭建--第一节
    linux常用命令
    Linux下定时任务的查看及取消
    WampServer环境安装
    Airtest断言方法
    Pycharm创建模板头部默认
    QPS/TPS简介
    简易全文搜索引擎设计
    如何在linux下检测内存泄漏
    箱线图(boxplot)简介与举例
  • 原文地址:https://www.cnblogs.com/radical/p/4171487.html
Copyright © 2020-2023  润新知