제출 #1296415

#제출 시각아이디문제언어결과실행 시간메모리
1296415huydayyVlak (COCI20_vlak)C++20
70 / 70
19 ms24852 KiB
#include <bits/stdc++.h> #define TASK "Vlak" #define int long long #define double long double #define fi first #define se second #define pb push_back #define ii pair<int, int> #define vi vector<int> #define vvi vector<vi> #define vii vector<ii> #define reset(f, x) memset(f, x, sizeof(f)) #define all(x) x.begin(), x.end() #define sz(x) (long long)x.size() #define FOR(i, a, b) for (int i = (a), _b = (b); i <= _b; ++i) #define FORD(i, b, a) for (int i = (b), _a = (a); i >= _a; --i) #define FORV(v, H) for (auto &v: H) #define __builtin_popcount __builtin_popcountll #define BIT(mask, i) ((mask >> i) & 1ll) #define MASK(i) (1ll << (i)) #define ONBIT(mask, i) (mask (1ll << (i))) #define OFFBIT(mask, i) (mask &~ (1ll << (i))) #define mid(l, r) ((l + r) >> 1) #define left(id) (id << 1) #define right(id) ((id << 1) 1) #define TIME (1.0 * clock() / CLOCKS_PER_SEC) #define UNIQUE(x) sort(all(x)); x.resize(distance(x.begin(), unique(all(x)))) #define BUG1(a) cout << a << '\n' #define BUG2(a, b) cout << a << " " << b << '\n' #define BUG3(a, b, c) cout << a << " " << b << " " << c << '\n' #define BUG4(a, b, c, d) cout << a << " " << b << " " << c << " " << d << '\n' #define BUG5(a, b, c, d, e) cout << a << " " << b << " " << c << " " << d << " " << e << '\n' #define BUG6(a, b, c, d, e, f) cout << a << " " << b << " " << c << " " << d << " " << e << " " << f << '\n' using namespace std; template <class X, class Y> bool maximize(X &A, const Y &B){ if (A < B) return A = B, true; return false; } template <class X, class Y> bool minimize(X &A, const Y &B){ if (A > B) return A = B, true; return false; } const int oo = 1e18; const int MOD = 1e9 + 7; const int MAXN = 2e5 + 100; const int LOG = 16; const int base = 311; const int BLOCK = 317; const int dx[] = {0, 0, 1, 0, -1}; const int dy[] = {0, 1, 0, -1, 0}; int N, M, id = 0; struct Node{ Node *child[26]; int res = 0, mask = 0, id = 0; }; Node *root = new Node(); int dp[MAXN][2]; struct Trie{ void add(string s, int t){ Node *p = root; FOR(i, 0, sz(s) - 1){ int k = s[i] - 'a'; if (p -> child[k] == nullptr){ p -> child[k] = new Node(); p -> child[k] -> id = ++id; } p = p -> child[k]; p -> mask |= MASK(t); } } bool solve(Node *p, int j = 1){ int i = p -> id; if (~dp[i][j]) return dp[i][j]; bool cur = 0; FOR(k, 0, 25){ if (p -> child[k] == nullptr) continue; if (BIT(p -> child[k] -> mask, j)) maximize(cur, !solve(p -> child[k], j ^ 1)); } return dp[i][j] = cur; } } Trie; main(){ if (fopen(TASK".inp", "r")){ freopen(TASK".inp", "r", stdin); freopen(TASK".out", "w", stdout); } ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> N; FOR(i, 1, N){ string s; cin >> s; Trie.add(s, 1); } cin >> M; FOR(i, 1, M){ string s; cin >> s; Trie.add(s, 0); } reset(dp, -1); cout << (Trie.solve(root) ? "Nina" : "Emilija") << '\n'; return 0; } /* ___ __ ___ _______ ___ ___ ________ ___ ________ ___ ___ ___ ___ ___ ___ \ \\ \ |\ \|\ ___ \ |\ \|\ \ |\ ____\|\ \|\ __ \ |\ \|\ \|\ \|\ \ |\ \ / / | \ \\ \ |\ \|\ ___ \ |\ \|\ \ |\ ____\|\ \|\ __ \ |\ \|\ \|\ \|\ \ |\ \ / / | \ \ \/ /|\ \ \ \ __/|\ \ \\\ \ \ \ \___|\ \ \ \ \|\ \ \ \ \\\ \ \ \\\ \ \ \ \/ / / \ \ ___ \ \ \ \ \_|/_\ \ \\\ \ \ \ \ __\ \ \ \ __ \ \ \ __ \ \ \\\ \ \ \ / / \ \ \\ \ \ \ \ \ \_|\ \ \ \\\ \ \ \ \|\ \ \ \ \ \ \ \ \ \ \ \ \ \ \\\ \ \/ / / \ \__\\ \__\ \__\ \_______\ \_______\ \ \_______\ \__\ \__\ \__\ \ \__\ \__\ \_______\__/ / / \|__| \|__|\|__|\|_______|\|_______| \|_______|\|__|\|__|\|__| \|__|\|__|\|_______|\___/ / \|___|/ Author: Kieu Gia Huy a.k.a kiwi From: C.H.V with luv <3 ... */

컴파일 시 표준 에러 (stderr) 메시지

Main.cpp:98:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   98 | main(){
      | ^~~~
Main.cpp: In function 'int main()':
Main.cpp:100:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
  100 |         freopen(TASK".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:101:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
  101 |         freopen(TASK".out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
#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...