跳到正文

算法·理论

TJ NOIp 2023 迷惑行为大赏

318cyz约 9 分钟
原文
文章信息与版本

文章信息

收录
2025年12月12日
更新
2025年12月12日
篇幅
约 9 分钟
获赞
2

版本

  1. v1当前

这里是 TJ 20232023 NOIp 迷惑行为大赏()

若您的代码被展示而您不愿被展示的,私信向我提出后我将会撤下您的代码;若有遗漏的也可向我反馈。

TJ 地区今年有 117117 人参加考试,实际 113113 人参加,44 人缺考。

共有 11 人留下了自己的洛谷 ID,是 TJ-0012 号(@培淇2021),在 tribool 一题:

共有 77 人注释了 freopen,其中实质性出错的有 44 人:(下列打 XX 的为实际有 freopen 的)

共有 00 人提到了关于 CCF 的内容。


卖萌的:

写游记的:

现场写题解的:

C++
#include<cstdio>
#include<iostream>
#include<cstring>
#include<string>
#include<algorithm>

using namespace std;

//有 n 个两两不同的、长度均为 m 的单词
//每个单词都是一个小写字母构成的字符串
//操作任意多次(可以不做)
//选择词典中的任意一个单词,交换其中任意两个字符
//是否可以通过以上操作得到新的 n 个单词
//w1,w2,w3,...,wn
//dict(wi).num<dict(wj).num

//#define int long long
#define MAXN 3000+5
int n, m;
int wrdnum[MAXN][MAXN];
//int stat[MAXN];
bool outpt[MAXN];
int m1num[30][30];
int m2num[30][30][15];

int main() {
	freopen("dict.in", "r", stdin);
	freopen("dict.out", "w", stdout);

	//输入
	scanf("%d%d", &n, &m);
	string cche;
	for(int i = 1 ; i <= n ; ++i) {
		cin >> cche;
		for(int j = 0 ; j < m ; ++j) {
			int cc = cche[j];
			wrdnum[i][j+1] = cc - 'a' +1;
		}
	}

	//可能存在的特判:
	//对于n = 1的情况,我们约定:
	//上述性质是自然成立的
	//如果题目描述中的性质成立,则 ai = 1
	if(n == 1) {
		printf("1");
		return 0;
	}

	//样例1~4:
	//只有一个字母,那我只需要遍历这个字典
	//找到最小的字母(可能不为一)输出1
	if(m == 1) {
		//处理:一个桶的思想
		//把每个字母按照字典序记录个数和位置
		//m1的第0位记录个数
		//从1开始记录每一个的位置
		for(int i = 1 ; i <= n ; ++i) {
			int wrdn = wrdnum[i][1];
			m1num[wrdn][0]++;
			int hdnm = m1num[wrdn][0];
			m1num[wrdn][hdnm] = i;
		}

		//从前向后遍历,如果这个字母出现了且最先被发现
		//那就说明这个是最小的字母(避免最小字母有多个)
		for(int i = 1 ; i <= 26 ; ++i) {
			int hdd = m1num[i][0];
			if(hdd > 0) {
				for(int j = 1 ; j <= hdd ; ++j) {
					outpt[m1num[i][j]] = true;
				}
				break;
			}
		}

		//输出
		for(int i = 1 ; i <= n ; ++i) {
			if(outpt[i] == true) {
				printf("1");
			} else {
				printf("0");
			}
		}

		return 0;
	}

	if(m == 2) {
		for(int i = 1 ; i <= n ; ++i) {
			bool lfgcheck = false;
			int vx1 = wrdnum[i][1];
			int vx2 = wrdnum[i][2];

			for(int j = 1 ; j <= n ; ++j) {
				if(i == j) {
					continue;
				}

				if(vx1 > wrdnum[j][1] && vx2 > wrdnum[j][1] &&vx1 > wrdnum[j][2] && vx2 > wrdnum[j][2]) {
					lfgcheck = true;
					break;
				}
			}

			if(lfgcheck == false) {
				outpt[i] = true;
			}
		}

		for(int i = 1 ; i <= n ; ++i) {
			if(outpt[i] == true) {
				printf("1");
			} else {
				printf("0");
			}
		}

		return 0;
	}

	fclose(stdin);
	fclose(stdout);

	return 0;
}

原神启动:

求佛祖保佑的(这位的 freopen 还把输入的文件名写成了 ans):

野兽先辈:

运气型选手:


上海市洛谷科技有限公司提示您:

算法千万条,细心第一条;
多测不清空,爆零两行泪。

这位更是玩起了 Dev-Cpp 模板项目里自带的小游戏:

C++
/*
	cout << "This is an easy guessing game" << endl;
	cout << "You have 12 times to guess" << endl;
	int t = 1;
	cout << "put your key: " << endl;
	int s;
	cin >> s;
		int k = randd(s + 107) % 100;

	while(1) {
		t++;
		cout << "put in you number:  ";
		int a;
		cin>> a;
		cout << endl;
		if(a > k) cout << '>' << endl;
		if(a < k) cout << '<' << endl;
		if(a == k) {
			cout << "wins" << endl;
			cout << "Again?" << endl;
			char c;
			cin>> c;
			if(c == 'y') {
	cout << "put your key: " << endl;
	int s;
	cin >> s;

				k = randd(s + 2353) % 100;
				t = 1;
			}
			else return 0;
		}
		if(t == 12) {
			cout << "YOU lose " << endl;
			cout << "play harder next time!!" << endl;
			return 0;
		}
	}
	*/
原文