链接

题意

思路

代码

#include<bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
set<pair<pair<int,int>,pair<int,int>>>st;
string s;
int x, y, lastx, lasty, ans;
int main()
{int T;cin >> T;while(T--){lastx = 0; lasty = 0;x = 0; y = 0; ans = 0;st.clear();cin >> s;for(int i = 0; i <= s.size()-1; i++){if(s[i]=='N') y++;else if(s[i]=='S') y--;else if(s[i]=='W') x--;else if(s[i]=='E') x++;if(st.count({{x,y},{lastx,lasty}}))ans += 1;else ans += 5, st.insert({{x,y},{lastx,lasty}}),st.insert({{lastx,lasty},{x,y}});lastx = x;lasty = y;}cout << ans << "\n";}return 0;
}

Codeforces Testing Round #16 (Unrated)C (集合)相关推荐

  1. Testing Round #16 (Unrated) C. Skier(map的应用)

    outputstandard output Skier rides on a snowy field. Its movements can be described by a string of ch ...

  2. Testing Round #16 (Unrated)

    B. Square? 题目链接:https://codeforces.ml/contest/1351/problem/B #include <bits/stdc++.h>#define r ...

  3. Codeforces Testing Round #14 (Unrated) C. Minimum Sum

    给你仅含有字符'a'~'j'的字符串,让你用字符'0'~'9'替换其中的字符,使得替换后所有字符串代表的整数之和最小,假设字符串并不会出现前导零. 数据规模:n(1<n<1000)个字符串 ...

  4. Codeforces Beta Round #16 (Div. 2 Only)【未完结】

    2022.3.9 题目地址:https://codeforces.com/contest/16 目录 A. Flag[模拟] B. Burglar and Matches[贪心] C. Monitor ...

  5. Codeforces Testing Round #10 A. Forgotten Episode

    水题,注意数据范围 #include <iostream> using namespace std;int main(){long long n,a;cin >> n;long ...

  6. [Educational Codeforces Round 16]A. King Moves

    [Educational Codeforces Round 16]A. King Moves 试题描述 The only king stands on the standard chess board ...

  7. Educational Codeforces Round 16 C. Magic Odd Square 矩阵构造

    传送门 文章目录 题意: 思路: 题意: 给你一个奇数nnn,让你构造一个n∗nn*nn∗n的矩阵,矩阵的每个位置依次填上[1,n∗n]之内的数[1,n*n]之内的数[1,n∗n]之内的数,满足每行. ...

  8. Codeforces Global Round 3

    Codeforces Global Round 3 A. Another One Bites The Dust 有若干个a,有若干个b,有若干个ab.你现在要把这些串拼成一个串,使得任意两个相邻的位置 ...

  9. Codeforces Global Round 14 F. Phoenix and Earthquake 思维 + 并查集

    传送门 文章目录 题意: 思路: 题意: 给你nnn个点,mmm条边,限制xxx,每个点都有沥青aia_iai​,定义合并两个点即两点之间有边且au+av≥xa_u+a_v\ge xau​+av​≥x ...

最新文章

  1. 记录遇到的Altium designer显示布线未完成坑
  2. eclipse如何修改dynamic web module version
  3. Asp.net中一个页面多个表单的解决方案
  4. 在WPF中弹出右键菜单时判断鼠标是否选中该项
  5. 2018实用前端面试问题集锦
  6. AT4439-[AGC028E]High Elements【结论,线段树】
  7. 带你一步一步深入Handler源码,醍醐灌顶!
  8. OpenCV-python学习笔记(五)——shreshoding阈值化
  9. [NOIp2008] 双栈排序 (二分图染色 + 贪心)
  10. python实现嵌套列表按指定位置元素排序、按子列表长度、子列表之和、绝对值和、最大/最小值排序
  11. 银河麒麟操作系统下载地址收集
  12. x509证书、openssl、go生成证书
  13. Chromium OS 初体验
  14. 【清华大学】操作系统 陈渝 Part4 ——物理内存管理 之 非连续内存分配
  15. MCTS (Monte Carlo Tree Search)
  16. 计算机体系结构-第五章-指令级并行
  17. Jmeter全方面讲解——Jmeter的安装
  18. Android下载保存gif图片
  19. mcnp的重复探测器单元计数-fmesh卡的介绍
  20. python判断字符串是否为回文if语句_如何python判断字符串是否为回文?

热门文章

  1. Android权限uses-permission
  2. Service通过onBind跨进程启动流程源码探究
  3. 3D建模的步骤小技巧
  4. 【正点原子STM32连载】 第二十五章 TFT-LCD(MCU屏)实验 摘自【正点原子】STM32F103 战舰开发指南V1.2
  5. iOS 基于LinPhone的语音通话
  6. Day02_MySQLLearning
  7. 用matplotlib画画,这个小海豚惊到我了
  8. 五一节,送给自己快乐
  9. 相机模型-鱼眼模型(fisheye camera model)
  10. 【机器学习】onehot编码的各种实现