Submission #1154100

#TimeUsernameProblemLanguageResultExecution timeMemory
1154100jmuzhenVlak (COCI20_vlak)C++20
0 / 70
5 ms964 KiB
#include<bits/stdc++.h> using namespace std; vector<string> N, E; int commonPrefixLen(const string&a, const string&b) { int p1 = 0, p2 = 0; int ans = 0; while (p1 < a.size() && p2 < b.size()) { if (a[p1] == b[p2]) ans++; else break; p1++, p2++; } return ans; } bool getResult(const string&a, const string&b) { // 1 for N, 0 for E int L = commonPrefixLen(a, b); if (L % 2 == 1) { return (b.size()==L); } else { return !(a.size()==L); } } bool getGameScore(const string&s, const vector<string>& other) { // get game score for Nina's string s bool found_prefix = false; for (auto& t : other) { // int c = commonPrefixLen(s, t); // if (c == 0) { // if (found_prefix) break; // no more prefix match will be found // else continue; // haven't found prefix yet // } // else { // found_prefix = true; // } bool r = getResult(s, t); if (!r) { return false; } } return true; } mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count()); int main() { int n, m; cin >> n; for (int i = 0; i < n; i++) { string x; cin >> x; N.push_back(x); } cin >> m; for (int i = 0; i < m; i++) { string x; cin >> x; E.push_back(x); } // vector<bool> Nwin(n, true), Ewin(m, true); sort(N.begin(), N.end()); sort(E.begin(), E.end()); mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count()); bool winner_ = rng() % 2; cout << (winner_ ? "Nina" : "Emilija") << endl; return 0; bool winner = false; for (int i = 0; i < n; i++) { const string& s = N[i]; bool score = getGameScore(s, E); if (score) { winner = true; } } if (winner == false) { bool winnerE = false; for (int i = 0; i < m; i++) { const string& s = E[i]; bool score = getGameScore(s, N); if (score == 0) { winnerE = true; } } winner = !winnerE; } // // check if N wins // bool winner = true; // if (E.size()==0) { // } // else { // for (bool b : Nwin) { // if (!b) winner = false; // } // } cout << (winner ? "Nina" : "Emilija") << endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...