Submission #487441

#TimeUsernameProblemLanguageResultExecution timeMemory
487441NimbostratusVlak (COCI20_vlak)C++17
20 / 70
17 ms13904 KiB
#include "bits/stdc++.h" using namespace std; #define endl '\n' using lint = long long; using pii = pair<int,int>; constexpr int maxn = 2e5+5; constexpr int maxc = 'z' + 10; constexpr int inf = 2e9; constexpr int mod = 1e9+7; int n, m; string s[maxn], t[maxn]; bool sc[maxn][maxc], tc[maxn][maxc], win[maxn][maxc]; vector<vector<bool>> dp; int maxl; signed main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cin >> n; for(int i = 0; i < n; i++) { cin >> s[i]; maxl = max(maxl, (int)s[i].size()); } cin >> m; for(int i = 0; i < m; i++) { cin >> t[i]; maxl = max(maxl, (int)t[i].size()); } for(int i = 0; i < n; i++) while(s[i].size() < maxl) s[i] += char('z' + 1); for(int i = 0; i < m; i++) while(t[i].size() < maxl) t[i] += char('z' + 2); dp = vector<vector<bool>>(maxl + 10, vector<bool>(max(n, m) + 10)); for(int k = 0; k < maxl; k++) for(int i = 0; i < n; i++) sc[k][s[i][k]] = true; for(int k = 0; k < maxl; k++) for(int i = 0; i < m; i++) tc[k][t[i][k]] = true; for(int i = 'a'; i <= 'z' + 2; i++) win[maxl][i] = true; for(int k = maxl - 1; k >= 0; k--) { bool f = k == maxl - 1; if(k % 2 == 0) { for(int i = 0; i < n; i++) { dp[k][i] = !tc[k][s[i][k]] || !win[k + 1][s[i][k]] || f; if(k >= 1) win[k][s[i][k - 1]] = win[k][s[i][k - 1]] || dp[k][i] || f; } } else { for(int i = 0; i < m; i++) { dp[k][i] = !sc[k][t[i][k]] || !win[k + 1][t[i][k]] || f; if(k >= 1) win[k][t[i][k - 1]] = win[k][t[i][k - 1]] || dp[k][i] || f; } } } bool ans = false; for(int i = 0; i < n; i++) ans |= dp[0][i]; cout << (ans ? "Nina" : "Emilija") << endl; }

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:32:21: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   32 |   while(s[i].size() < maxl)
      |         ~~~~~~~~~~~~^~~~~~
Main.cpp:35:21: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   35 |   while(t[i].size() < maxl)
      |         ~~~~~~~~~~~~^~~~~~
Main.cpp:42:17: warning: array subscript has type 'char' [-Wchar-subscripts]
   42 |    sc[k][s[i][k]] = true;
      |                 ^
Main.cpp:45:17: warning: array subscript has type 'char' [-Wchar-subscripts]
   45 |    tc[k][t[i][k]] = true;
      |                 ^
Main.cpp:53:30: warning: array subscript has type 'char' [-Wchar-subscripts]
   53 |     dp[k][i] = !tc[k][s[i][k]] || !win[k + 1][s[i][k]] || f;
      |                              ^
Main.cpp:53:54: warning: array subscript has type 'char' [-Wchar-subscripts]
   53 |     dp[k][i] = !tc[k][s[i][k]] || !win[k + 1][s[i][k]] || f;
      |                                                      ^
Main.cpp:55:24: warning: array subscript has type 'char' [-Wchar-subscripts]
   55 |      win[k][s[i][k - 1]] = win[k][s[i][k - 1]] || dp[k][i] || f;
      |                        ^
Main.cpp:55:46: warning: array subscript has type 'char' [-Wchar-subscripts]
   55 |      win[k][s[i][k - 1]] = win[k][s[i][k - 1]] || dp[k][i] || f;
      |                                              ^
Main.cpp:60:30: warning: array subscript has type 'char' [-Wchar-subscripts]
   60 |     dp[k][i] = !sc[k][t[i][k]] || !win[k + 1][t[i][k]] || f;
      |                              ^
Main.cpp:60:54: warning: array subscript has type 'char' [-Wchar-subscripts]
   60 |     dp[k][i] = !sc[k][t[i][k]] || !win[k + 1][t[i][k]] || f;
      |                                                      ^
Main.cpp:62:24: warning: array subscript has type 'char' [-Wchar-subscripts]
   62 |      win[k][t[i][k - 1]] = win[k][t[i][k - 1]] || dp[k][i] || f;
      |                        ^
Main.cpp:62:46: warning: array subscript has type 'char' [-Wchar-subscripts]
   62 |      win[k][t[i][k - 1]] = win[k][t[i][k - 1]] || dp[k][i] || f;
      |                                              ^
#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...