• P1199-三国游戏


     1 #include <bits/stdc++.h>
     2 using namespace std;
     3 typedef long long ll;
     4 typedef double db;
     5 #define INF 0x3f3f3f3f
     6 #define _for(i,a,b) for(int i = (a);i < b;i ++)
     7 #define _rep(i,a,b) for(int i = (a);i > b;i --)
     8 
     9 inline ll read()
    10 {
    11     ll ans = 0;
    12     char ch = getchar(), last = ' ';
    13     while(!isdigit(ch)) last = ch, ch = getchar();
    14     while(isdigit(ch)) ans = (ans << 1) + (ans << 3) + ch - '0', ch = getchar();
    15     if(last == '-') ans = -ans;
    16     return ans;
    17 }
    18 inline void write(ll x)
    19 {
    20     if(x < 0) x = -x, putchar('-');
    21     if(x >= 10) write(x / 10);
    22     putchar(x % 10 + '0');
    23 }
    24 int n; 
    25 int a[503][503];
    26 int main()
    27 {
    28     n = read();
    29     _for(i,1,n+1)
    30         _for(j,1,n+1)
    31             if(i == j)
    32                 a[i][j] = -1;
    33             else if(i < j)
    34                 a[i][j] = read();
    35             else
    36                 a[i][j] = a[j][i];
    37 
    38     int rnt = 0;
    39     priority_queue<int> pq;
    40     _for(i,1,n+1)
    41     {
    42         while(!pq.empty())
    43             pq.pop();
    44         _for(j,1,n+1)
    45         {
    46             if(pq.size()<2)
    47             {
    48                 pq.push(a[i][j]);
    49                 continue;
    50             }
    51             else if(a[i][j]>pq.top())
    52             {
    53                 int t1 = pq.top();
    54                 pq.pop();pq.pop();
    55                 pq.push(a[i][j]);
    56                 pq.push(t1);
    57                 continue;
    58             }
    59             int tmp = pq.top();
    60             pq.pop();
    61             if(a[i][j]>pq.top())
    62             {
    63                 pq.pop();
    64                 pq.push(a[i][j]);
    65             }
    66             pq.push(tmp);    
    67         }
    68         pq.pop();
    69         rnt = max(rnt,pq.top());
    70     }
    71     printf("1
    %d",rnt);
    72     return 0;
    73 }
  • 相关阅读:
    Balanced Number [ZOJ 3416]
    动态树
    Jason的特殊爱好 [FZU 2113]
    Raney引理
    Tri Tiling [POJ 2663]
    糖尿病的虾青素+胰岛素疗法 (转)
    JAVASCRIPT 开发工具:aptana ,WebStorm
    众志和达,英文SOUL 存储与数据安全提供商
    健身音乐及其它
    nodejs + CompoundJS 资源
  • 原文地址:https://www.cnblogs.com/Asurudo/p/11457733.html
Copyright © 2020-2023  润新知