This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define file_io freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
#define fast_io ios::sync_with_stdio(false);cin.tie(0);
#define what(x) cerr << #x << " is " << x << '\n';
#define kill(x) {cout << x << '\n'; return 0;}
#define all(x) (x).begin(), (x).end()
#define pii pair<int, int>
#define pb push_back
#define ll long long
#define F first
#define S second
const ll inf = 1e18, mod = 1e9 + 7, delta = 1e9 + 9, SQ = 450, P = 6065621;
using namespace std;
const ll N = 2e5 + 10, LG = 31;
int a[N], b[N];
int main() {
fast_io;
string s, t;
cin >> s >> t;
for (auto u: s) a[u]++;
char ans;
int ans1, ans2;
for (int i = 0; i < s.size(); i++) {
if (b[s[i]]) {
ans1 = i;
ans = s[i];
}
}
for (int i = 0; i < t.size(); i++) {
if (t[i] == ans) {
ans2 = i;
break;
}
}
cout << 1 << '\n' << ans1 << ' ' << ans2 << '\n';
return 0;
}
Compilation message (stderr)
necklace.cpp: In function 'int main()':
necklace.cpp:23:21: warning: array subscript has type 'char' [-Wchar-subscripts]
23 | for (auto u: s) a[u]++;
| ^
necklace.cpp:26:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
26 | for (int i = 0; i < s.size(); i++) {
| ~~^~~~~~~~~~
necklace.cpp:27:15: warning: array subscript has type 'char' [-Wchar-subscripts]
27 | if (b[s[i]]) {
| ^
necklace.cpp:32:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
32 | for (int i = 0; i < t.size(); i++) {
| ~~^~~~~~~~~~
necklace.cpp:38:47: warning: 'ans2' may be used uninitialized in this function [-Wmaybe-uninitialized]
38 | cout << 1 << '\n' << ans1 << ' ' << ans2 << '\n';
| ^~~~
necklace.cpp:38:32: warning: 'ans1' may be used uninitialized in this function [-Wmaybe-uninitialized]
38 | cout << 1 << '\n' << ans1 << ' ' << ans2 << '\n';
| ^~~
necklace.cpp:33:5: warning: 'ans' may be used uninitialized in this function [-Wmaybe-uninitialized]
33 | if (t[i] == ans) {
| ^~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |