풀이
https://codeforces.com/problemset/problem/1419/A
걸린 시간
02 : 00 : 00 실패
풀이
C++
#include <bits/stdc++.h>
#define INF 1e9
typedef long long ll;
using namespace std;
int n, digit;
vector<pair<int, int>> odd, even;
int main(){
int tc;
scanf("%d", &tc);
while(tc--){
scanf("%d", &n);
odd.clear(); even.clear();
for(int i = 1; i <= n; i++){
scanf("%1d", &digit);
if(i%2 == 0)
even.push_back(make_pair(-(digit%2), digit));
else
odd.push_back(make_pair(digit%2, digit));
}
sort(odd.begin(), odd.end());
sort(even.begin(), even.end());
if(odd.size() == even.size())
if(even[even.size()-1].second%2 == 0)
printf("%d\n", 2);
else
printf("%d\n", 1);
else
if(odd[odd.size()-1].second%2 == 0)
printf("%d\n", 2);
else
printf("%d\n", 1);
}
return 0;
}
시간 안에 풀지 못한 이유 :
no matter how Raze plays "Raze 가 어떻게 시작해도 문제가 없다."
no matter how Raze plays "Raze 가 시작할 방법이 없다."
'Codeforces' 카테고리의 다른 글
Codeforces 1419D2 Saga's Birthday (hard version) (0) | 2020.09.21 |
---|---|
Codeforces 1419D1 Sage's Birthday (easy version) (0) | 2020.09.21 |
Codeforces #1409C Yet Another Array Restoration (0) | 2020.09.19 |
Codeforces #1409B Minimum Product (0) | 2020.09.18 |
Codeforces #1399B Gifts Fixing (0) | 2020.09.18 |
댓글