Codeforces Round #478 (Div. 2)

本文详细解析了Codeforces Round #478 (Div. 2)的四道题目,包括A题Aramic script的字符统计、B题Mancala的奇偶数石头分配模拟、C题Valhalla Siege的勇士防御与攻击策略以及D题Ghosts中幽灵相遇的几何与物理分析。通过这些题目的解答,探讨ACM竞赛中的思维与技巧。
摘要由CSDN通过智能技术生成

掉分场,第四题应该细心下来算一下样例

A. Aramic script

题目大意:给定n个字符串,统计有多少不同的字符串,字符串不同当且仅当出现的字符(不考虑次数)不同,只有小写字母。
题解:hash一下,丢进Set里

#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define CLR(a) memset(a, 0, sizeof(a))
#define DBG(x) cout<<(#x)<<"="<<x<<endl
#define FOR(i, a, b)  for(int i=(a); i<(b); i++)
#define REP(i, a, b)  for(int i=(a); i<=(b); i++)
#define DOWN(i, a, b) for(int i=(a); i>=(b); i--)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const double eps = 1e-8;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const ll mod = 1000000009;
const int N= 5e4 +10;

int n;
ll t;
int len;
set<ll> S;
string s;
ll w[30], vis[30];

int main() {
    cin>>n;
    w[0]=1;
    FOR(i, 1, 26) w[i]=w[i-1]*2;
    REP(i, 1, n) {
        cin>>s;
        len=s.length();
        memset(vis, 0, sizeof(vis));
        FOR(j, 0, len) {
            vis[s[j]-'a']=1;
        }
        t=0;
        FOR(j, 0, 26) {
            t+=vis[j]*w[j];
        }
        S.insert(t);
    }
    cout<<S.size()<<endl;
    //cout<<1.*clock()/CLOCKS_PER_SEC<<"ms"<<"\n";
    return <
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值