zoukankan      html  css  js  c++  java
  • 【noip系列——模拟】玩具谜题

    P1563 玩具谜题

    noip2016day1T1

    去年做只有85分,于是给我幼小的心灵留下了巨大的创伤QAQ一直没有改

    然而刚刚发现真*签到题qwq

    因为它好歹也是noip真题啊所以贴一贴代码啦qwq

     1 #include<cstdio>
     2 #include<cstring>
     3 #include<iostream>
     4 using namespace std;
     5 const int sz = 100010;
     6 int n, m;
     7 int fang, sum;
     8 struct node {
     9     int dir;
    10     string name;
    11 }p[sz];
    12 string ans;
    13 int main() {
    14     scanf("%d%d",&n,&m);
    15     for(int i = 1; i <= n;  i++) {
    16         scanf("%d",&p[i].dir);
    17         cin>>p[i].name;
    18     }
    19     int now = 1;
    20     for(int j = 1; j <= m; j++) {
    21         scanf("%d%d",&fang,&sum);
    22         if(fang == p[now].dir) { //顺时针 
    23             if(now > sum) now -= sum;
    24             else if(now == sum) now = n;
    25             else {
    26                 sum = sum - now;
    27                 now = n - sum;
    28             } 
    29         }
    30         else {  //逆时针 
    31             if(now + sum <= n) now += sum;
    32             else {
    33                 sum = sum - n + now;
    34                 now = sum;
    35             }
    36             
    37         }
    38     }
    39     cout<<p[now].name;
    40     return 0;
    41 }
    总之岁月漫长,然而值得期待。
  • 相关阅读:
    脏读、不可重复读、幻读
    数据库一致性
    java 不同时间格式转化
    python-walk遍历目录及查找目录小例子
    python_os模块
    python_time模块
    exec和eval内置函数
    python-filter函数
    python-map函数
    python_内置函数
  • 原文地址:https://www.cnblogs.com/Hwjia/p/9720352.html
Copyright © 2011-2022 走看看