Submission #660268

#TimeUsernameProblemLanguageResultExecution timeMemory
660268berrPalindromi (COCI22_palindromi)C++17
0 / 110
1085 ms7776 KiB
#include <bits/stdc++.h> using namespace std; #define int long long const int N=2e5+37; string s[N]; int val[N]; int check(string t) { for(int i=0; i<t.size(); i++) { if(t[i]!=t[t.size()-i-1]) return 0; } return 1; } void merge(int x, int y) { string t=s[x]+s[y]; set<string> st; for(int i=0; i<t.size(); i++) { string f; for(int l=i; l<t.size(); l++) { f+=t[l]; if(check(f)) { st.insert(f); } } } s[x]=s[y]=t; val[x]=val[y]=st.size(); } int32_t main() { ios_base::sync_with_stdio(false); cin.tie(0); int n; cin>>n; string sr; cin>>sr; for(int i=0; i<n; i++) { s[i]=sr[i]; val[i]=1; } for(int i=0; i<n-1; i++) { int x, y; cin>>x>>y; x--; y--; merge(x, y); cout<<val[x]<<endl; } }

Compilation message (stderr)

Main.cpp: In function 'long long int check(std::string)':
Main.cpp:10:19: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   10 |     for(int i=0; i<t.size(); i++)
      |                  ~^~~~~~~~~
Main.cpp: In function 'void merge(long long int, long long int)':
Main.cpp:23:19: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   23 |     for(int i=0; i<t.size(); i++)
      |                  ~^~~~~~~~~
Main.cpp:26:23: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |         for(int l=i; l<t.size(); l++)
      |                      ~^~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...