Archives
Trending
Support
Login
clear text
XML
Django
JavaScript
MATLAB
C
C++
C#
Python
SQL
Shell
Bash
Markdown
YAML
JSON
HTML
CSS
PHP
Java
Ruby
Go
Rust
Swift
Kotlin
Arduino
TypeScript
Perl
Autohotkey
Lua
SQF
R
Scala
Haskell
Groovy
Dart
Clojure
VB.NET
Objective-C
PowerShell
Bash
CoffeeScript
Verilog
#include
#include
#include
#include
using namespace std; int n, m; vector
> graph[105]; int dp[105][105][30][2]; // +INF -- max win // -INF -- lucas win int rec(int max_node, int lucas_node, int last_char, int turn) { if(dp[max_node][lucas_node][last_char][turn] != -1) { return dp[max_node][lucas_node][last_char][turn]; } int result; if(turn == 0) { result = -(2e9); for(int i = 0; i < graph[max_node].size(); i++) { int neighbour = graph[max_node][i].first; int val = (int) graph[max_node][i].second; if(last_char <= val) { result = max(result, rec(neighbour, lucas_node, val, 1)); } } } else { result = (2e9); for(int i = 0; i < graph[lucas_node].size(); i++) { int neighbour = graph[lucas_node][i].first; int val = (int) graph[lucas_node][i].second; if(last_char <= val) { result = min(result, rec(max_node, neighbour, val, 0)); } } } return dp[max_node][lucas_node][last_char][turn] = result; } int main() { ios_base::sync_with_stdio(false); cin >> n >> m; for(int i = 0; i < m; i++) { int a, b; char c; cin >> a >> b >> c; a--; b--; graph[a].push_back(make_pair(b, (c - 'a') + 1)); } memset(dp, -1, sizeof dp); for(int i = 0; i < n; i++) { for(int j = 0; j < n; j++) { if(rec(i, j, 0, 0) == 2e9) { cout << "A"; } else { cout << "B"; } } cout << endl; } return 0; }
Mark as private (unlisted)
for 30 minutes
for 6 hours
for 1 day
for 1 week
for 1 month
for 1 year
everlasting (like CCCP)