跳到正文

题解

题解:P11751 [COCI 2024/2025 #5] 呜哇 / Wow

AC_Seed约 1 分钟
原文
文章信息与版本

文章信息

收录
2025年12月12日
更新
2026年5月8日
篇幅
约 1 分钟
题目
P11751

版本

  1. v1当前

这是一道简单的字符串题。 解题思路:

  • 我们可以遍历整个字符串,如果上一个字符是 / 且字符 aia_i 为 .。如果 t=4t=4 就是 v,否则是 w。tt 的作用会在下午阐述。
  • 否则我们 t=t+1t=t+1。在这里,我们的 tt 是一个计数器,用于统计当前连续的字符个数。 代码:
C++
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	string a;
	cin>>n>>a;
	int t=0;
	for(int i=0;i<n;i++){
		if(a[i-1]=='/'&&a[i]=='.'){
			if(t==4) cout<<'v';
			else cout<<'w';
		    t=0;
		}
		else t++;
	}
	if(t==4) cout<<'v';
	else cout<<'w';
	return 0;
}
原文