ABC366整理

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 2 2 维) 题

先不考虑 * , 初始化字符串,全弄成*,然后,对于每个 i i i j j j ,将 S i S_i Si 的第 j j j 个字符分配给 T j T_j Tj 的第 ( N − i + 1 ) (N-i+1) (Ni+1) 个字符。现在,除了第二个条件外,所有条件都满足了。要满足第二个条件,对于每个 T i T_i Ti ,重复删除以 * 结尾的最后一个字符。

点击查看代码
#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);
}



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值