Submission #202591

#TimeUsernameProblemLanguageResultExecution timeMemory
202591detaomegaLampice (COCI19_lampice)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; #define X first #define Y second #define rep(i,a,b) for(int i=a;i<=b;i++) #define IOS ios::sync_with_stdio(0);cin.tie(0); #define de(x,y) cout<<#x<<" :"<<x<<y; #define int long long #define SZ(xx) ((int)xx.size()) #define lowbit(xx) (xx&(-xx)) #define pb push_back typedef pair<int,int> pii; const int maxn = 4e5+5; int arr[maxn], ans = 0; vector<int> vt, G[maxn]; double start; bool check() { vector<int> rvt = vt; reverse(rvt.begin(), rvt.end()); for(int i=0; i<vt.size(); i++) { if(vt[i]^rvt[i]) return 0; } return 1; } void dfs(int now,int fa) { vt.push_back(arr[now]); if(check()) ans = max(ans, SZ(vt)); for(int k:G[now]) if(k != fa) dfs(k, now); vt.pop_back(); if((clock()-start)/CLOCKS_PER_SEC>4.9)) { cout << ans << "\n"; exit(0); } } void solve() { string s; cin >> s; int ans = 1 , len = s.size(); for(int i=0;i<s.size()-1;i++) { int tmp = 1; for(int j=1;j<=s.size();j++) { if(i-j < 0 || i+j >= len) break; if(s[i - j] != s[i + j]) break; tmp += 2; } ans = max(ans , tmp); if(s[i] == s[i+1]) { tmp = 2; for(int j=1;j<=s.size();j++) { if(i-j < 0 || i+j+1 >= len) break; if(s[i - j] != s[i + j+1]) break; tmp += 2; } } ans = max(ans , tmp); if(ans == len) break; } cout << ans << "\n"; } main() { IOS start = clock(); mt19937 mt_rand(time(0)); double start=clock(); int n; cin >> n; for(int i=1; i<=n; i++) { char c; cin >> c; arr[i] = c - 'a'; } for(int i=1; i<n; i++) { int u, v; cin >> u >> v; G[u].push_back(v); G[v].push_back(u); } for(int i=1; i<=n; i++) { dfs(i, 0); } cout << ans << "\n"; }

Compilation message (stderr)

lampice.cpp: In function 'bool check()':
lampice.cpp:21:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0; i<vt.size(); i++) {
               ~^~~~~~~~~~
lampice.cpp: In function 'void dfs(long long int, long long int)':
lampice.cpp:36:40: error: expected primary-expression before ')' token
  if((clock()-start)/CLOCKS_PER_SEC>4.9)) {
                                        ^
lampice.cpp: In function 'void solve()':
lampice.cpp:46:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for(int i=0;i<s.size()-1;i++) {  
                     ~^~~~~~~~~~~
lampice.cpp:48:26: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             for(int j=1;j<=s.size();j++) {  
                         ~^~~~~~~~~~
lampice.cpp:58:30: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
                 for(int j=1;j<=s.size();j++) {  
                             ~^~~~~~~~~~
lampice.cpp: At global scope:
lampice.cpp:73:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main() {
      ^
lampice.cpp: In function 'int main()':
lampice.cpp:78:9: warning: unused variable 'start' [-Wunused-variable]
  double start=clock();
         ^~~~~