아 어이업서~~~
입력 잘못 받아서 틀렸다ㅋㅋㅋㅋ
보면 100101 이런식으로 연속해서 값이 들어오기 떄문에
%1d 로 입력받거나 아님 문자열로 입력 받았어야 했다ㅋㅋㅋ
이거 중간에 알았었는데 왜 고칠 생각을 못했을까.
다른 방법이 있을 줄 알았다.
암튼 간단히 1d로 고쳐서 해결~~~
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <functional>
#include <string>
#include <queue>
#include <stack>
#include <set>
using namespace std;
using i64 = long long;
int main() {
int n, a, b;
scanf("%1d %1d %1d", &n, &a, &b);
vector <int> v(n);
for (int i = 0; i < n; i++)
{
scanf("%1d", &v[i]);
}
if (v[a-1] == v[b-1])
printf("0");
else
printf("1");
return 0;
}
뭐가 문제니
또 틀렸다
그래서 벡터로 만든 거 문자열로 바꿨다.
벡터에 잘 들어온 거 확인했는데 왜...
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <functional>
#include <string>
#include <queue>
#include <stack>
#include <set>
using namespace std;
using i64 = long long;
int main() {
int n, a, b;
scanf("%1d %1d %1d", &n, &a, &b);
string v;
cin >> v;
if (v[a-1] == v[b-1])
printf("0");
else
printf("1");
return 0;
}
벡터로 해서 틀린 거 문자열로 고친다고 해결 되겠냐;
틀렸다
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <functional>
#include <string>
#include <queue>
#include <stack>
#include <set>
using namespace std;
using i64 = long long;
int main() {
int n, a, b;
scanf("%d %d %d", &n, &a, &b);
string v;
cin >> v;
if (v[a-1] == v[b-1])
printf("0");
else
printf("1");
return 0;
}
ㅋㅋ
ㅋㅋㅋㅋ
ㅋㅋ
n, a, b는 또 왜 1d로 받았냐ㅋㅋㅋ
ㅋㅋ
한자리 수만 받아서 문제였다.
이제는 통과함...
'코드포스' 카테고리의 다른 글
[코드포스 Practice17] C. MUH and Important Things (0) | 2020.04.11 |
---|---|
[코드포스 Practice17] B. Bus of Characters (0) | 2020.04.11 |
[코드포스 Practice17] 후기 (0) | 2020.04.11 |
[코드포스 Practice16] E. Squares and not squares (0) | 2020.04.05 |
[코드포스 Practice16] D. Yet Another Walking Robot (0) | 2020.04.05 |