QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#474472 | #5499. Aliases | piratZnachor# | WA | 12ms | 16656kb | C++14 | 3.4kb | 2024-07-12 18:57:58 | 2024-07-12 18:57:58 |
Judging History
answer
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
#define INF 1000000000
#define INFl 1000000000000000000
#define all(x) x.begin(), x.end()
#define sajz(x) (int)x.size()
#define pb push_back
#define se second
#define fi first
#define yes puts("YES")
#define no puts("NO")
#define erase_duplicates(x) {sort(all(x));(x).resize(distance((x).begin(), unique(all(x))));}
using namespace std;
//using namespace __gnu_pbds;
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
//#define int ll
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef set<int> si;
typedef multiset<int> msi;
typedef long double ld;
//typedef cc_hash_table<int, int, hash<int>> ht;
const int N = 2e5 + 5;
string s[N][2];
int cyfry(int x) {
if (x <= 1) return 0;
int c = 0;
while (true) {
int mam = (c == 0 ? 0 : pow(10, c));
if (mam >= x) return c;
c ++;
}
assert(false);
return -1;
}
void test_case() {
int n;
cin >> n;
for (int i = 1; i <= n; i ++) {
cin >> s[i][0] >> s[i][1];
}
vector<int> ans = {0, 0, 6};
int best_sum = 6; // max wynik to 6, bo 10^6 > N
for (int a = 0; a <= 5; a ++) {
for (int b = 0; b <= 5; b ++) {
if (a + b >= best_sum) continue;
unordered_map<string, int> mapka;
int maks = 0;
for (int i = 1; i <= n; i ++) {
string id = "";
if (a >= s[i][0].size()) id += s[i][0];
else id += s[i][0].substr(0, a);
if (b >= s[i][1].size()) id += s[i][0];
else id += s[i][1].substr(0, b);
mapka[id] ++;
maks = max(maks, mapka[id]);
}
int c = cyfry(maks);
//if (c) continue;
if (a + b + c < best_sum) {
best_sum = a + b + c;
ans = {a, b, c};
}
mapka.clear();
}
}
for (int i = 0; i < 3; i ++) cout << ans[i] << ' ';
cout << '\n';
}
int32_t main() {
ios_base::sync_with_stdio(false);
cout.tie(0);
cin.tie(0);
int z;
cin >> z;
while (z--) {
test_case();
}
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 16584kb
input:
1 11 sven eriksson erik svensson sven svensson erik eriksson bjorn eriksson bjorn svensson bjorn bjornsson erik bjornsson sven bjornsson thor odinsson odin thorsson
output:
0 0 2
result:
ok correct! (1 test case)
Test #2:
score: -100
Wrong Answer
time: 12ms
memory: 16656kb
input:
6 1 g u 14643 gj ek hc bi hi ke ab ij hk cj ha bi ag fe eb ej hd ei bf gj ke dd ib jd id jb gd ei cj bi bi hg ic dh ke gk af eg fg dd fe fa be ge hf kj ih ci gg jf ed dd eh gi cc kd ka fd af gb ka fe ja ed bc hi eg cf gg ff kf gf ii ch hh ec ei ec cd gc bh hb dd id ce bk ib ic bf kk gh cd hb he if g...
output:
0 0 0 0 0 5 0 1 1 1 0 2 1 1 1 2 0 1
result:
wrong answer Loginy nie moga byc puste! (test case 1)