zoukankan      html  css  js  c++  java
  • 【HDOJ】3587 NUDOTA

    字符串模拟水题。

      1 /* 3587 */
      2 #include <iostream>
      3 #include <cstdio>
      4 #include <cstring>
      5 #include <cstdlib>
      6 #include <string>
      7 #include <map>
      8 using namespace std;
      9 
     10 #define MAXN 1005
     11 
     12 typedef struct {
     13     bool f;
     14     int k;
     15     int t;
     16     int v;
     17 } hero_t;
     18 
     19 hero_t hero[MAXN*2];
     20 int nn = 0;
     21 char x[55], y[55];
     22 map<string, int> tb;
     23 map<string, int>::iterator iter;
     24 
     25 int main() {
     26     int n, m, K;
     27     int i, j, k, tmp;
     28     char cmd[3];
     29     int t;
     30     bool fb;
     31     int ck[11];
     32     
     33     #ifndef ONLINE_JUDGE
     34         freopen("data.in", "r", stdin);
     35     #endif
     36     
     37     ck[0] = ck[1] = ck[2] = 0;
     38     for (i=3; i<=10; ++i)
     39         ck[i] = ck[i-1] + 50;
     40     
     41     while (scanf("%d %d %d", &n, &m, &K) != EOF) {
     42         nn = 0;
     43         tb.clear();
     44         for (i=0; i<n; ++i) {
     45             scanf("%s", x);
     46             tb[string(x)] = nn;
     47             hero[nn].v = 603;
     48             hero[nn].k = 0;
     49             hero[nn].t = 0;
     50             hero[nn].f = true;
     51             ++nn;
     52         }
     53         for (i=0; i<m; ++i) {
     54             scanf("%s", x);
     55             tb[string(x)] = nn;
     56             hero[nn].v = 603;
     57             hero[nn].k = 0;
     58             hero[nn].t = 0;
     59             hero[nn].f = false;
     60             ++nn;
     61         }
     62         
     63         fb = true;
     64         while (K--) {
     65             scanf("%s", cmd);
     66             if (cmd[0] == 'K') {
     67                 scanf("%s %s %d", x, y, &t);
     68                 i = tb[string(x)];
     69                 j = tb[string(y)];
     70                 if (hero[i].f ^ hero[j].f) {
     71                     k = 200;
     72                     ++hero[i].k;
     73                     if (fb) {
     74                         fb = false;
     75                         k += 200;
     76                     }
     77                     if (hero[i].k > 10)
     78                         k += ck[10];
     79                     else
     80                         k += ck[hero[i].k];
     81                     hero[i].v += (t-hero[i].t) + k;
     82                     hero[i].t = t;
     83                 }
     84                 hero[j].v = hero[j].v + (t-hero[j].t) - 300;
     85                 hero[j].t = t;
     86                 hero[j].k = 0;
     87                 if (hero[j].v < 0)
     88                     hero[j].v = 0;
     89             } else {
     90                 scanf("%s %d", x, &t);
     91                 i = tb[string(x)];
     92                 hero[i].v += (t - hero[i].t);
     93                 hero[i].t = t;
     94                 printf("%d
    ", hero[i].v);
     95             }
     96         }
     97     }
     98     
     99     return 0;
    100 }
  • 相关阅读:
    建立连接数据库时要输入哪些信息?
    如何建立一个JDBC程序?
    如何在网上找MySQL数据库的JDBC驱动jar包?
    gorm连接mysql数据库
    Django ORM的骚操作
    Python 发送企业微信单发和群发机器人
    python获取指定间隔日期列表
    表名小写_set.all()再根据字段过滤
    foreignkey相关的参数
    Django 模型层-多表操作
  • 原文地址:https://www.cnblogs.com/bombe1013/p/4241256.html
Copyright © 2011-2022 走看看