제출 #921048

#제출 시각아이디문제언어결과실행 시간메모리
921048shoryu386Necklace (Subtask 1-3) (BOI19_necklace1)C++17
5 / 85
1509 ms916 KiB
#include <bits/stdc++.h> using namespace std; #define int long long #define MOD 1'000'000'007LL #define MAX 200'007 main(){ ios_base::sync_with_stdio(0); cin.tie(0); string a, b; cin >> a >> b; int n = a.size(), m = b.size(); int ans = -1; int resA, resB; for (int x = 0; x < n; x++){ for (int y = x; y < n; y++){ string hmm; for (int z = x; z <= y; z++) hmm.push_back(a[z]); unordered_set<string> hash; hash.insert(hmm); for (int x = 0; x < hmm.size(); x++){ rotate(hmm.begin(), hmm.begin()+1, hmm.end()); hash.insert(hmm); } reverse(hmm.begin(), hmm.end()); hash.insert(hmm); for (int x = 0; x < hmm.size(); x++){ rotate(hmm.begin(), hmm.begin()+1, hmm.end()); hash.insert(hmm); } string cur = ""; for (int z = 0; z <= (y-x); z++){ cur.push_back(b[z]); } if (cur == hmm){ if (ans < (y-x+1)){ ans = y-x+1; resA = x, resB = 0; } } for (int z = 1; z+(y-x) < m; z++){ //cur.pop_front(); cur.erase(cur.begin()); //slow cur.push_back(b[z+y-x]); if (hash.count(cur)){ if (ans < (y-x+1)){ ans = y-x+1; resA = x, resB = z; } } } } } cout << ans << '\n'; cout << resA << ' ' << resB; }

컴파일 시 표준 에러 (stderr) 메시지

necklace.cpp:9:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    9 | main(){
      | ^~~~
necklace.cpp: In function 'int main()':
necklace.cpp:28:22: 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]
   28 |    for (int x = 0; x < hmm.size(); x++){
      |                    ~~^~~~~~~~~~~~
necklace.cpp:35:22: 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]
   35 |    for (int x = 0; x < hmm.size(); x++){
      |                    ~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...