链接:

https://vjudge.net/problem/CodeForces-721A

题意:

Recently Adaltik discovered japanese crosswords. Japanese crossword is a picture, represented as a table sized a × b squares, and each square is colored white or black. There are integers to the left of the rows and to the top of the columns, encrypting the corresponding row or column. The number of integers represents how many groups of black squares there are in corresponding row or column, and the integers themselves represents the number of consecutive black squares in corresponding group (you can find more detailed explanation in Wikipedia https://en.wikipedia.org/wiki/Japanese_crossword).

Adaltik decided that the general case of japanese crossword is too complicated and drew a row consisting of n squares (e.g. japanese crossword sized 1 × n), which he wants to encrypt in the same way as in japanese crossword.Help Adaltik find the numbers encrypting the row he drew.

思路:

模拟算一下,

代码:

#include <bits/stdc++.h>
using namespace std;int main()
{ios::sync_with_stdio(false);cin.tie(0);string s;int n;cin >> n >> s;vector<int> res;int cnt = 0;int tmp = 0, in = 0;for (int i = 0;i < s.length();i++){if (s[i] == 'B'){if (in)tmp++;else{tmp = 1;in = 1;}}else{if (in){res.push_back(tmp);in = 0;cnt++;}}}if (in){res.push_back(tmp);in = 0;cnt++;}cout << cnt << endl;for (int i = 0;i < res.size();i++)cout << res[i] << ' ' ;cout << endl;return 0;
}

转载于:https://www.cnblogs.com/YDDDD/p/11380279.html

CodeForces-721A-One-dimensional Japanese Crossword相关推荐

  1. 【codeforces 721A】One-dimensional Japanese Crossword

    A. One-dimensional Japanese Crossword time limit per test 1 second memory limit per test 256 megabyt ...

  2. Codeforces Round #374 (Div. 2) A. One-dimensional Japanese Crosswor 水题

    A. One-dimensional Japanese Crossword 题目连接: http://codeforces.com/contest/721/problem/A Description ...

  3. CodeForces 90B African Crossword【模拟】

    African Crossword Time Limit:2000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u ...

  4. 【Codeforces】 Round #374 (Div. 2)

    Position:http://codeforces.com/contest/721 我的情况 开始还是rank1,秒出C.(11:00机房都走光了,我ma到11:05才走,只打了一个小时) 结果.. ...

  5. 【Codeforces】A2组刷题记录(50 / 50)完结

    目录 A1. Counterexample A2. Good Number A3. Dice Tower ★A4. Alyona and Numbers A5. Mountain Scenery rz ...

  6. Codeforces Round #374 (Div. 2) A , B , C 水,水,拓扑dp

    A. One-dimensional Japanese Crossword time limit per test 1 second memory limit per test 256 megabyt ...

  7. CCPC-Wannafly Summer Camp 2019 全记录

    // 7.19-7.29 东北大学秦皇岛校区十天训练营,题目都挂在了Vjudge上.训练期间比较忙,没空更博总结,回来继续补题消化. Day1 这天授课主题是简单图论,节奏挺好,wls两小时理完图论里 ...

  8. Codeforces 90B-African Crossword

    African Crossword time limit per test 2 seconds memory limit per test 256 megabytes input standard i ...

  9. codeforces 884B Japanese Crosswords Strike Back

    http://codeforces.com/problemset/problem/884/B 给出一个长度,表示一个二进制的数的长度,再给出n个数,用二进制来表示,如果1101则表示2和12个数,即连 ...

  10. codeforces 850 A

    codeforces 850 A A. Five Dimensional Points introduction 在n个点中,是否存在一个点,与另外任意两个点连成的向量,为锐角 method 首先在2 ...

最新文章

  1. TRex 学习 (4) ---- stateful ( advanced )
  2. 谈协同软件实施特点与过程
  3. Python之pyspark:pyspark的简介、安装、使用方法之详细攻略
  4. 安装引导黑屏_南京课工场IT培训:引导过程与服务控制(理论笔记篇)
  5. 对象 对象 java 1615134277
  6. ant 改变表格数据_React ant design表格导出数据为EXCEL表格数据
  7. LeetCode—Python版数组简单题(二)
  8. python 保存图片_python 输出文档到world
  9. java并发编程实战源码_java并发编程实战(附源码)
  10. DZ先生怪谈GAT1400之视图库系统架构
  11. miui怎么用第三方图标包_【教程纪】原生ROM养老指南:图标篇
  12. python小学教材全解_小学教材全解五年级数学上人教版
  13. Ccharles 爬取微信公众号和小程序
  14. csp202109-1:数组推导 题解
  15. 如何截图一张完整的表_wps2016表格太长怎么截图打印?
  16. 为什么走线选择50欧姆阻抗
  17. Peewee基本使用
  18. sudo chmod -R 777
  19. Linux下查看内存型号、主板、硬盘等等
  20. 工作区、暂存区、仓库三者关系

热门文章

  1. 考试周来临。。蓦然回首
  2. 计算机网络:循环冗余码CRC
  3. win10系统电脑提示此程序被组策略阻止的解决办法
  4. 在linux下 配置内网ip`
  5. 如何取消html5微信页面授权,微信授权登录网页管理在哪里看?如何取消授权
  6. Unity 2017-2019各个版本unityhub下载连接
  7. android google翻译,在android中施用google翻译
  8. 通用评估神经网络鲁棒性方法—CLEVER
  9. 转:关于启用 HTTPS 的一些经验分享(二)
  10. FAT16 FAT32 NTFS exFAT ReFS