ABC366整理:
C:
用一个变量存储背包内现有的球种类数
注: 可能会重
模拟即可
简单的C++ code:
#include <bits/stdc++.h>
//#include <windows.h>
//#include <unistd.h>
using namespace std;
#define endl '\n'
#define TRACE 1
#define tcout TRACE && cout
#define fst ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define int long long
#define all(a) (a).begin(),(a).end()
#define rep(name, start, end) for(int name = (start); name <= (end); i ++)
#define xs(n) cout << fixed << setprecision(n)
const int P = 998244353;
const int Base = 3221225477;
const int INF = 0x3f3f3f3f3f3f3f3f;
const int N = 1e6 + 10, M = 2e6 + 10;
int read()
{
int x = 0, w = 1;
char ch = 0;
while (ch < '0' || ch > '9')
{
if (ch == '-') w = -1;
ch = getchar();
}
while (ch >= '0' && ch <= '9')
{
x = x * 10 + (ch - '0');
ch = getchar();
}
return x * w;
}
void write(int x)
{
if (x < 0)
{
x = -x;
putchar('-');
}
if (x > 9) write(x / 10);
putchar(x % 10 + '0');
}
signed main()
{
fst;
int n = read();
int cnt = 0;
map <int, int> mp;
while (n --)
{
int op, x;
cin >> op;
if(op == 1)
{
cin >> x;
mp[x] ++;
if(mp[x] == 1)
{
cnt ++;
}
}
else if(op == 2)
{
cin >> x;
mp[x] --;
if(mp[x] > 0)
{
;
}
else
{
cnt ---;
}
}
else
{
cout << cnt << endl;
}
}
exit(0);
}
B:
矩阵( \(2\) 维) 题
先不考虑 *
, 初始化字符串,全弄成*
,然后,对于每个 \(i\) 和 \(j\) ,将 \(S_i\) 的第 \(j\) 个字符分配给 \(T_j\) 的第 \((N-i+1)\) 个字符。现在,除了第二个条件外,所有条件都满足了。要满足第二个条件,对于每个 \(T_i\) ,重复删除以 *
结尾的最后一个字符。
点击查看代码
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define TRACE 1
#define tcout TRACE && cout
#define fst ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define int long long
const int P = 998244353;
const int Base = 2281701377;
const int INF = 0x3f3f3f3f3f3f3f3f;
const int N = 1e2 + 10, M = 2e6 + 10;
int n;
char a[N][N];
int len[N];
int maxn;
char b[N][N];
signed main()
{
memset(a, '*', sizeof(a));
cin >> n;
for(int i=1; i<=n; i++)
{
string s;
cin >> s;
len[i] = s.size();
for(int j=1; j<=len[i]; j++)
{
a[i][j] = s[j-1];
}
maxn = max(maxn, len[i]);
}
for(int i=1, x=1; i<=maxn; i++, x++)
{
for(int j=n, y=1; j>=1; j--, y++)
{
b[x][y] = a[j][i];
}
}
for(int i=1; i<=maxn; i++)
{
for(int j=n; j>=1; j--)
{
if(b[i][j] != '*')
{
break;
}
else
{
b[i][j] = ' ';
}
}
}
for(int i=1; i<=maxn; i++)
{
for(int j=1; j<=n; j++)
{
cout << b[i][j];
}
cout << endl;
}
return 0;
}
A
简单啊!难道还有人 ${\LARGE {\color{Red}Wrong \ Answer} } $ ?
点击查看代码
#include <bits/stdc++.h>
//#include <windows.h>
//#include <unistd.h>
using namespace std;
#define endl '\n'
#define TRACE 1
#define tcout TRACE && cout
#define fst ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define int long long
#define all(a) (a).begin(),(a).end()
#define rep(name, start, end) for(int name = (start); name <= (end); i ++)
#define xs(n) cout << fixed << setprecision(n)
const int P = 998244353;
const int Base = 3221225477;
const int INF = 0x3f3f3f3f3f3f3f3f;
const int N = 1e6 + 10, M = 2e6 + 10;
int read()
{
int x = 0, w = 1;
char ch = 0;
while (ch < '0' || ch > '9')
{
if (ch == '-') w = -1;
ch = getchar();
}
while (ch >= '0' && ch <= '9')
{
x = x * 10 + (ch - '0');
ch = getchar();
}
return x * w;
}
void write(int x)
{
if (x < 0)
{
x = -x;
putchar('-');
}
if (x > 9) write(x / 10);
putchar(x % 10 + '0');
}
signed main()
{
fst;
int n, a, b;
cin >> n >> a >> b;
if((a < b and a + (n - a- b) < b) or (b < a and b + (n - a- b) < a))
{
cout << "Yes";
}
else
{
cout << "No";
}
exit(0);
}