답안 #880946

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
880946 2023-11-30T09:05:53 Z vjudge1 Necklace (Subtask 1-3) (BOI19_necklace1) C++17
0 / 85
1 ms 348 KB
#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

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) {
      |     ^~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -