跳到正文

题解

题解:P13307 域名判断

Kei__约 3 分钟
原文
文章信息与版本

文章信息

收录
2025年12月12日
更新
2025年12月12日
篇幅
约 3 分钟
题目
P13307

版本

  1. v1当前

首先把所有小写字母改为大写,然后枚举 .EDU.CN,同时记录 . 的数量,在找到 .EDU.CN 时前面需要存在至少一个 .。找到一个满足要求的下标就输出一个下标。

C++
#include<bits/stdc++.h>
//#define int long long
#define I_love_Foccarus return
#define cin_fast ios::sync_with_stdio(false) , cin.tie(0) , cout.tie(0)
#define endl '\n'
//#define getchar getc
#define pii pair<int,int>
#define mk(a,b) make_pair(a,b)
#define fi first
#define se second
#define pd(a) push_back(a)
#define in(a) a = read_int()
using namespace std;
const int Size = 1 << 14;
const int N = 1e5 + 5;
const int inf = 0x3f3f3f3f;
const long long INF = 0x3f3f3f3f3f3f3f3f;
inline char getc(){
	static char syn[Size] , *begin = syn , *end = syn;
	if(begin == end) begin = syn , end = syn + fread(syn , 1 , Size , stdin);
	I_love_Foccarus *begin ++;
}
inline int read_int() {
	int x = 0;
	char ch = getchar();
	bool f = 0;
	while('9' < ch || ch < '0') f |= ch == '-' , ch = getchar();
	while('0' <= ch && ch <= '9') x = (x << 3) + (x << 1) + ch - '0' , ch = getchar();
	I_love_Foccarus f ? -x : x;
}
int h;
signed main() {
	//cin_fast;
    string a;
	cin>>a;
	for(int i = 0 ; i < a.size() ; i ++) {
		if('a' <= a[i] && a[i] <= 'z') a[i] -= 32;
 	}
 	for(int i = 1 ; i < a.size() ; i ++) {
 		if(i + 5 <= a.size() && a[i - 1] == '.' && a[i] == 'E' && a[i + 1] == 'D' && a[i + 2] == 'U' && a[i + 3] == '.' && a[i + 4] == 'C' && a[i + 5] == 'N' && h >= 1) {
 			h ++;
			cout<<i + 6<<' ';
 			i += 5;
		}
		if(a[i] == '.') h ++;
	 }



	I_love_Foccarus 0;
}

原文