NM-S00251 代码迷惑行为大赏

· · 休闲·娱乐

upd:此人已被 CCF 核实作弊,并作出禁赛处理

省流:

0+100+70+4

//如果你看到这里了 ,那我就可以告诉你一个“惊喜 ”
//我不知道会不会有人看这个代码,工整吧
//半个小时 才写出来的
//这个没有road多
//我妈给我报的课我基本没上,纯跟AI学
//AI讲的可明白多了,还是1对1
//总之,看到的话不要惊讶
//昨天AI告诉我,可读的变量名可以让人读的更清楚 
//我本来没打算这么写来着,但是有趣的是Deepseek严厉的批评了我
//所以特意去英语速成啦 
//至于这个应该没人看见,因为是机器判题

club 编码:UTF-8

#include <iostream>
using namespace std;

int main(){

cout<<"不会"<<endl;
return 0;
}

road 编码:UTF-8

#include <bits/stdc++.h>
using namespace std;

struct FastInput {
    static const int BUFSIZE = 1 << 20;
    int idx, len;
    char buf[BUFSIZE];
    FastInput() : idx(0), len(0) {}
    inline char nextChar() {
        if (idx >= len) {
            len = fread(buf, 1, BUFSIZE, stdin);
            idx = 0;
            if (len == 0) return 0;
        }
        return buf[idx++];
    }
    template <typename T>
    bool read(T &out) {
        char c = 0;
        T sign = 1, val = 0;
        c = nextChar();
        if (!c) return false;
        while (c != '-' && (c < '0' || c > '9')) {
            c = nextChar();
            if (!c) return false;
        }
        if (c == '-') {
            sign = -1;
            c = nextChar();
        }
        for (; c >= '0' && c <= '9'; c = nextChar())
            val = val * 10 + (c - '0');
        out = val * sign;
        return true;
    }
};

struct Edge {
    int u, v;
    long long w;
    int mask;
};

struct DSU {
    vector<int> parent, rnk, cityCnt;
    DSU(int n = 0) { init(n); }
    void init(int n) {
        parent.resize(n + 1);
        rnk.assign(n + 1, 0);
        cityCnt.assign(n + 1, 0);
        for (int i = 1; i <= n; ++i) parent[i] = i;
    }
    int find(int x) {
        while (parent[x] != x) {
            parent[x] = parent[parent[x]];
            x = parent[x];
        }
        return x;
    }
    bool unite(int a, int b, int &cityComp) {
        int ra = find(a), rb = find(b);
        if (ra == rb) return false;
        bool ca = cityCnt[ra] > 0;
        bool cb = cityCnt[rb] > 0;
        if (rnk[ra] < rnk[rb]) swap(ra, rb);
        parent[rb] = ra;
        cityCnt[ra] += cityCnt[rb];
        if (rnk[ra] == rnk[rb]) ++rnk[ra];
        if (ca && cb) --cityComp;
        return true;
    }
};

int main() {
    freopen("road.in", "r", stdin);
    freopen("road.out", "w", stdout);
    FastInput in;
    int n, m, k;
    if (!in.read(n)) return 0;
    in.read(m);
    in.read(k);
    vector<Edge> edges;
    edges.reserve((long long)m + (long long)n * k);

    for (int i = 0; i < m; ++i) {
        int u, v;
        long long w;
        in.read(u);
        in.read(v);
        in.read(w);
        edges.push_back({u, v, w, 0});
    }

    vector<long long> costTown(k);
    for (int j = 0; j < k; ++j) {
        long long cj;
        in.read(cj);
        costTown[j] = cj;
        for (int i = 1; i <= n; ++i) {
            long long a;
            in.read(a);
            edges.push_back({n + 1 + j, i, a, 1 << j});
        }
    }

    sort(edges.begin(), edges.end(), [](const Edge &a, const Edge &b) { return a.w < b.w; });

    int totalNodes = n + k;
    DSU dsu(totalNodes);

    int totalMasks = 1 << k;
    vector<long long> addCost(totalMasks, 0);
    for (int mask = 1; mask < totalMasks; ++mask) {
        int lb = __builtin_ctz(mask);
        addCost[mask] = addCost[mask ^ (1 << lb)] + costTown[lb];
    }

    long long answer = LLONG_MAX;

    for (int mask = 0; mask < totalMasks; ++mask) {
        dsu.init(totalNodes);
        for (int i = 1; i <= n; ++i) dsu.cityCnt[i] = 1;
        int cityComp = n;
        long long mstCost = 0;
        for (const auto &e : edges) {
            if (e.mask && ((mask & e.mask) == 0)) continue;
            if (dsu.unite(e.u, e.v, cityComp)) {
                mstCost += e.w;
                if (cityComp == 1) break;
            }
        }
        long long total = mstCost + addCost[mask];
        if (total < answer) answer = total;
    }

    printf("%lld\n", answer);
    return 0;
}

replace 编码:UTF-8

#include <bits/stdc++.h>
using namespace std;

typedef unsigned long long ull;

const ull BASE = 1315423911ull;
const size_t MAXLEN = 5000000 + 5;
const long long COMBO_LIMIT = 200000;

static ull pw[MAXLEN];

struct PairKey {
    ull h1, h2;
    int len;
    bool operator==(const PairKey& other) const noexcept {
        return h1 == other.h1 && h2 == other.h2 && len == other.len;
    }
};

struct KeyHash {
    size_t operator()(const PairKey& k) const noexcept {
        return (size_t)(k.h1 ^ (k.h2 * 1000003ull) ^ ((ull)k.len * 19260817ull));
    }
};

ull get_hash(const vector<ull>& pre, int l, int len) {
    return pre[l + len] - pre[l] * pw[len];
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    pw[0] = 1;
    for (size_t i = 1; i < MAXLEN; ++i) pw[i] = pw[i - 1] * BASE;

    ifstream fin("replace.in");
    ofstream fout("replace.out");
    int n, q;
    fin >> n >> q;

    unordered_map<PairKey, int, KeyHash> mp;
    mp.reserve(n * 2);

    struct UP { ull h1, h2; int len; int cnt; };
    vector<UP> uniq;
    uniq.reserve(n);

    auto hash_string = [&](const string& s) -> ull {
        ull h = 0;
        for (char c : s) h = h * BASE + (ull)(c - 'a' + 1);
        return h;
    };

    for (int i = 0; i < n; ++i) {
        string a, b;
        fin >> a >> b;
        int len = (int)a.size();
        ull h1 = hash_string(a);
        ull h2 = hash_string(b);
        PairKey key{h1, h2, len};
        auto it = mp.find(key);
        if (it == mp.end()) {
            int idx = (int)uniq.size();
            mp[key] = idx;
            uniq.push_back({h1, h2, len, 1});
        } else {
            ++uniq[it->second].cnt;
        }
    }

    for (int qi = 0; qi < q; ++qi) {
        string s, t;
        fin >> s >> t;
        int m = (int)s.size();
        if ((int)t.size() != m) {
            fout << 0 << '\n';
            continue;
        }

        int l0 = -1, r0 = -1;
        for (int i = 0; i < m; ++i) {
            if (s[i] != t[i]) { l0 = i; break; }
        }
        if (l0 == -1) {
            fout << 0 << '\n';
            continue;
        }
        for (int i = m - 1; i >= 0; --i) {
            if (s[i] != t[i]) { r0 = i; break; }
        }
        int diffLen = r0 - l0 + 1;

        long long combos = (long long)(l0 + 1) * (m - r0);

        vector<ull> ps(m + 1), pt(m + 1);
        ps[0] = pt[0] = 0;
        for (int i = 0; i < m; ++i) {
            ps[i + 1] = ps[i] * BASE + (ull)(s[i] - 'a' + 1);
            pt[i + 1] = pt[i] * BASE + (ull)(t[i] - 'a' + 1);
        }

        long long ans = 0;

        if (combos <= COMBO_LIMIT) {
            for (int pos = 0; pos <= l0; ++pos) {
                int minLen = r0 - pos + 1;
                for (int len = minLen; pos + len <= m; ++len) {
                    ull hs = get_hash(ps, pos, len);
                    ull ht = get_hash(pt, pos, len);
                    PairKey key{hs, ht, len};
                    auto it = mp.find(key);
                    if (it != mp.end()) ans += uniq[it->second].cnt;
                }
            }
        } else {
            for (const auto& up : uniq) {
                int len = up.len;
                if (len < diffLen) continue;
                int start = r0 - len + 1;
                if (start < 0) start = 0;
                int end = l0;
                if (start > end) continue;
                for (int pos = start; pos <= end; ++pos) {
                    ull hs = get_hash(ps, pos, len);
                    if (hs != up.h1) continue;
                    ull ht = get_hash(pt, pos, len);
                    if (ht != up.h2) continue;
                    ans += up.cnt;
                }
            }
        }

        fout << ans << '\n';
    }

    return 0;
}
//如果你看到这里了 ,那我就可以告诉你一个“惊喜 ”
//我不知道会不会有人看这个代码,工整吧
//半个小时 才写出来的
//这个没有road多
//我妈给我报的课我基本没上,纯跟AI学
//AI讲的可明白多了,还是1对1
//总之,看到的话不要惊讶
//昨天AI告诉我,可读的变量名可以让人读的更清楚 
//我本来没打算这么写来着,但是有趣的是Deepseek严厉的批评了我
//所以特意去英语速成啦 
//至于这个应该没人看见,因为是机器判题

employ 编码:ANSI

#include <bits/stdc++.h>
using namespace std;
int main(){
    ifstream fin("employ.in");
    ofstream fout("employ.out");
    long long n,m; 
    if(!(fin>>n>>m)) return 0;
        string s; fin>>s;
    for(int i=0;i<n;i++){long long x; fin>>x;}
        fout<<0<<'\n';
    return 0;
}//错了这个,就不整理了