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; void solving(string x, string y, int lx, int ly){ vector
res; vector
> mark(lx, vector
(ly)); int max = 0; for(int i = 0; i < lx; i++){ for(int j = 0; j < ly; j++){ if(x[i] != y[j]){ mark[i][j] = 0; continue; } if(i == 0 || j == 0){ mark[i][j] = 1; }else{ mark[i][j] = mark[i - 1][j - 1] + 1; } if(mark[i][j] > max){ max = mark[i][j]; res.clear(); res.push_back(x.substr(i + 1 - max, (i + 1) - (i + 1 - max))); }else if(mark[i][j] == max){ res.push_back(x.substr(i + 1 - max, (i + 1) - (i + 1 - max))); } } } sort(res.begin(), res.end()); cout << res[0] << endl; } string evolve(string temp){ string a = temp; a.erase(remove_if(a.begin(), a.end(), [](char c){ return c == ',' || c == '.' || c == '!' || c == '?'; }), a.end()); transform(a.begin(), a.end(), a.begin(), ::toupper); return a; } int main(){ string x, y; cin >> x >> y; string X = evolve(x); string Y = evolve(y); int m = x.length(); int n = y.length(); solving(X, Y, m, n); 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)