QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#93568 | #5499. Aliases | HCPS42# | WA | 46ms | 17920kb | C++17 | 3.8kb | 2023-04-01 17:12:13 | 2023-04-01 17:12:15 |
Judging History
answer
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <cmath>
#include <algorithm>
#include <cassert>
#include <chrono>
#include <random>
#include <string>
#include <numeric>
#include <complex>
#include <tuple>
#include <utility>
#include <bitset>
#include <array>
#include <stack>
#include <sstream>
using namespace std;
typedef long long ll;
string to_string(string a) { return '"' + a + '"'; }
string to_string(const char* a) { return to_string((string) a); }
string to_string(bool a) { return a ? "true" : "false"; }
template <class T1, class T2>
string to_string(pair<T1, T2> a) {
return "(" + to_string(a.first) + ", " + to_string(a.second) + ")";
}
template <class T>
string to_string(T a) {
bool first = true; string res = "{";
for (const auto& i : a) {
if (!first) res += ", ";
first = false;
res += to_string(i);
}
res += "}";
return res;
}
void debug_out() { cerr << endl; }
template <class T1, class... T2>
void debug_out(T1 a, T2... b) {
cerr << " " << to_string(a);
debug_out(b...);
}
#ifdef LOCAL
#define out(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define out(...) 42
#endif
clock_t start_time; void start_timer() { start_time = clock(); }
double get_time() { return (double) (clock() - start_time) / CLOCKS_PER_SEC; }
void Solve();
int main() {
ios_base::sync_with_stdio(0); cin.tie(0);
#ifdef LOCAL
freopen("usr/share/man/man1/input.txt", "r", stdin);
#endif
start_timer();
Solve();
#ifdef LOCAL
cerr << fixed << setprecision(3);
cerr << endl << "Time spent: " << get_time() << endl;
#endif
return 0;
}
// do something, stay focused
// look for stupid bugs
// guess, slow, stress
// don't overgeneralize
// don't rush
// don't waste time on standings
// SOLVE THE PROBLEM OR DIE TRYING
// THE SOLUTION IS ALWAYS SIMPLE
// THE CODE IS ALWAYS SHORT
// DON'T BACK DOWN
// STAND YOUR GROUND
// IT'S NOT POSSIBLE
// NO, IT'S NECESSARY
const int N = 2e5 + 5;
string s[N];
string t[N];
int lg[N];
map<string, int> cnt;
void Solve() {
{
lg[1] = 0;
int ten = 1;
int deg = 0;
while (ten < N) {
for (int i = ten + 1; i <= min(N - 1, 10 * ten); i++) {
lg[i] = deg + 1;
}
deg++;
ten *= 10;
}
}
int T;
cin >> T;
while (T--) {
int n;
cin >> n;
for (int i = 1; i <= n; i++) {
cin >> s[i] >> t[i];
}
int ans = lg[n];
int A = 0;
int B = 0;
int C = lg[n];
for (int a = 0; a <= 6; a++) {
for (int b = 0; b <= 6; b++) {
for (int c = 0; c <= 6; c++) {
if (a + b + c >= ans) continue;
cnt.clear();
for (int i = 1; i <= n; i++) {
string cur;
cur += s[i].substr(0, min(a, (int) s[i].size()));
cur += t[i].substr(0, min(b, (int) t[i].size()));
cnt[cur]++;
}
bool ok = 1;
for (auto [x, y] : cnt) {
if (lg[y] > c) {
ok = 0;
break;
}
}
if (ok) {
ans = a + b + c;
A = a;
B = b;
C = c;
}
}
}
}
cout << A << " " << B << " " << C << "\n";
}
}
详细
Test #1:
score: 100
Accepted
time: 2ms
memory: 16708kb
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: 46ms
memory: 17920kb
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)