結果
問題 |
No.2178 Payable Magic Items
|
ユーザー |
![]() |
提出日時 | 2022-09-27 04:18:55 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
RE
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 1,254 bytes |
コンパイル時間 | 2,592 ms |
コンパイル使用メモリ | 215,000 KB |
最終ジャッジ日時 | 2025-02-07 16:59:23 |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 RE * 3 |
other | AC * 1 RE * 22 |
ソースコード
// 愚直高速化 unordered_set<string> ver. #include <bits/stdc++.h> using namespace std; using Int = long long; constexpr static int mod = 1e9 + 7; constexpr static int inf = (1 << 30) - 1; constexpr static Int infll = (1LL << 61) - 1; int Competitive_Programming = (ios_base::sync_with_stdio(false), cin.tie(nullptr), cout << fixed << setprecision(15), 0); int main() { int N, K; cin >> N >> K; vector<string> s(N); vector<int> d(N); for (int i = 0; i < N; i++) cin >> s[i]; vector<unordered_set<string>> st(32); sort(s.begin(), s.end(), [](string &a, string &b) { int ret1 = 0, ret2 = 0; for (int j = 0; j < a.size(); j++) ret1 += abs(a[j] - 'D'), ret2 += abs(b[j] - 'D'); return ret1 > ret2; }); for (int i = 0; i < N; i++) { for (int j = 0; j < K; j++) d[i] += abs(s[i][j] - 'D'); st[d[i]].insert(s[i]); } int ans = 0; for (int i = 0; i < N; i++) { for (int j = 0; j < d[i]; j++) { vector<string> del; for (auto &&t : st[j]) { if (s[i] == t) continue; int cnt = 0; for (int k = 0; k < K; k++) cnt += (s[i][k] <= t[k]); if (cnt == K) { del.emplace_back(t); ans++; } } for (auto &&a : del) st[j].erase(a); } } cout << ans << "\n"; }