板子就不说了。
P2786 英语1(eng1)- 英语作文
红黑树 map 随便做,用一个 map 存下字符串对应的值,一个字符一个字符读入,然后判断, 如果不是数字并且不是字母,说明空格或者符号,处理答案。
/**
* author: TLE_Automation
* creater: 2022.9.7
**/
#include<cmath>
#include<queue>
#include<cstdio>
#include<bitset>
#include<cstring>
#include<iostream>
#include<algorithm>
#define gc getchar
using namespace std;
typedef long long ll;
const int N = 1e6 + 10;
const int mod = 998244353;
const ll inf = 0x3f3f3f3f3f3f3f3f;
#define debug cout << "i ak ioi" << "\n"
inline void print(int x) {if (x < 0) putchar('-'), x = -x; if(x > 9) print(x / 10); putchar(x % 10 + '0');}
inline char readchar() {static char buf[100000], *p1 = buf, *p2 = buf; return p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 100000, stdin), p1 == p2) ? EOF : *p1++;}
inline int read() { int res = 0, f = 0; char ch = gc();for (; !isdigit(ch); ch = gc()) f |= (ch == '-'); for (; isdigit(ch); ch = gc()) res = (res << 1) + (res << 3) + (ch ^ '0'); return f ? -res : res;}
#include <unordered_map>
int n, p, ans;
char ch; string t;
unordered_map <string, int> mp;
signed main()
{
n = read(), p = read();
for(int i = 1; i <= n; i++) {
string s; cin >> s; mp[s] = read();
}
while((ch = getchar()) && ch != EOF) {
if(!isdigit(ch) && !isalpha(ch)) ans = (ans + mp[t]) % p, t = "";
else t += ch;
}
printf("%d\n", ans);
return (0 - 0);
}
标签:ch,记录,int,char,p1,做题,平衡,include,buf
From: https://www.cnblogs.com/tttttttle/p/16667986.html