Codeforces Testing Round #16 (Unrated)C (集合)
链接
题意
思路
代码
#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 (集合)相关推荐
- 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 ...
- Testing Round #16 (Unrated)
B. Square? 题目链接:https://codeforces.ml/contest/1351/problem/B #include <bits/stdc++.h>#define r ...
- Codeforces Testing Round #14 (Unrated) C. Minimum Sum
给你仅含有字符'a'~'j'的字符串,让你用字符'0'~'9'替换其中的字符,使得替换后所有字符串代表的整数之和最小,假设字符串并不会出现前导零. 数据规模:n(1<n<1000)个字符串 ...
- Codeforces Beta Round #16 (Div. 2 Only)【未完结】
2022.3.9 题目地址:https://codeforces.com/contest/16 目录 A. Flag[模拟] B. Burglar and Matches[贪心] C. Monitor ...
- Codeforces Testing Round #10 A. Forgotten Episode
水题,注意数据范围 #include <iostream> using namespace std;int main(){long long n,a;cin >> n;long ...
- [Educational Codeforces Round 16]A. King Moves
[Educational Codeforces Round 16]A. King Moves 试题描述 The only king stands on the standard chess board ...
- Educational Codeforces Round 16 C. Magic Odd Square 矩阵构造
传送门 文章目录 题意: 思路: 题意: 给你一个奇数nnn,让你构造一个n∗nn*nn∗n的矩阵,矩阵的每个位置依次填上[1,n∗n]之内的数[1,n*n]之内的数[1,n∗n]之内的数,满足每行. ...
- Codeforces Global Round 3
Codeforces Global Round 3 A. Another One Bites The Dust 有若干个a,有若干个b,有若干个ab.你现在要把这些串拼成一个串,使得任意两个相邻的位置 ...
- Codeforces Global Round 14 F. Phoenix and Earthquake 思维 + 并查集
传送门 文章目录 题意: 思路: 题意: 给你nnn个点,mmm条边,限制xxx,每个点都有沥青aia_iai,定义合并两个点即两点之间有边且au+av≥xa_u+a_v\ge xau+av≥x ...
最新文章
- 记录遇到的Altium designer显示布线未完成坑
- eclipse如何修改dynamic web module version
- Asp.net中一个页面多个表单的解决方案
- 在WPF中弹出右键菜单时判断鼠标是否选中该项
- 2018实用前端面试问题集锦
- AT4439-[AGC028E]High Elements【结论,线段树】
- 带你一步一步深入Handler源码,醍醐灌顶!
- OpenCV-python学习笔记(五)——shreshoding阈值化
- [NOIp2008] 双栈排序 (二分图染色 + 贪心)
- python实现嵌套列表按指定位置元素排序、按子列表长度、子列表之和、绝对值和、最大/最小值排序
- 银河麒麟操作系统下载地址收集
- x509证书、openssl、go生成证书
- Chromium OS 初体验
- 【清华大学】操作系统 陈渝 Part4 ——物理内存管理 之 非连续内存分配
- MCTS (Monte Carlo Tree Search)
- 计算机体系结构-第五章-指令级并行
- Jmeter全方面讲解——Jmeter的安装
- Android下载保存gif图片
- mcnp的重复探测器单元计数-fmesh卡的介绍
- python判断字符串是否为回文if语句_如何python判断字符串是否为回文?