• hdoj1571


    下沙小面的(1)
    代码
    #include<iostream>
    #include
    <stdio.h>
    #include
    <string.h>
    using namespace std;
    int NCity, T, dist[30][30], K, pn, ans, P[7], now;    //dist距离,pn人数,now现在的车站
    int main()
    {
        
    while (scanf("%d"&NCity) != EOF && NCity) {
        pn 
    = 0, now = 0, ans = 0;
        
    for (int i = 0; i < NCity; ++i)
            
    for (int j = 0; j < NCity; ++j)
            scanf(
    "%d"&dist[i][j]);
        scanf(
    "%d"&K);
        
    char ch1, ch2;
        
    while (K--) {
            cin 
    >> ch1 >> ch2;
            
    if (ch1 == 'U') {    //有人上车
            scanf("%d"&T);
            
    if (pn == 7 || T == now)
                
    continue;    //人満
            P[pn] = T;
            pn
    ++;
            } 
    else {        //开车
            if (pn == 0)
                
    continue;
            ans 
    += dist[now][P[0]];
            now 
    = P[0];
            
    int tem[7];
            
    int ptem = 0;
            
    for (int pos = 0; pos < pn; ++pos) {
                
    if (P[pos] == now) {
                
    continue;
                }
                tem[ptem
    ++= P[pos];
            }
            
    for (int pos = 0; pos < ptem; ++pos)
                P[pos] 
    = tem[pos];
            pn 
    = ptem;
            }
        }
        printf(
    "%d\n", ans);
        }
    }


  • 相关阅读:
    react开发环境搭建
    react 组件创建
    Redux 视频教程
    echars3.0 柱状图y轴字体斜放
    echars3.0 柱状图大小设置
    ECharts地图详解 【转】
    html 超出出现省略号
    html JS打印添加水印图片
    js 重庆38区县 数组
    docker 暴露2375 端口。
  • 原文地址:https://www.cnblogs.com/Open_Source/p/1904954.html
Copyright © 2020-2023  润新知