提出 #373395
ソースコード 拡げる
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include <sstream>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <numeric>
#include <cctype>
#include <tuple>
#include <array>
#include <climits>
#include <bitset>
#include <cassert>
#include <unordered_map>
#include <complex>
#ifdef _MSC_VER
#include <agents.h>
#endif
#define FOR(i, a, b) for(int i = (a); i < (int)(b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define REV(v) v.rbegin(), v.rend()
#define MEMSET(v, s) memset(v, s, sizeof(v))
#define UNIQUE(v) (v).erase(unique(ALL(v)), (v).end())
#define MP make_pair
#define MT make_tuple
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
const int N = 1e5 + 10;
set<int> G[N];
int col[N];
void dfs(int v, int c){
if (col[v] >= 0){
assert(col[v] == c);
return;
}
col[v] = c;
for (auto to : G[v]){
dfs(to, c ^ 1);
}
}
int main(){
cin.tie(0);
ios::sync_with_stdio(false);
cout.setf(ios::fixed);
cout.precision(20);
int t;
cin >> t;
vector<string> a(t), sa;
rep(i, t){
cin >> a[i];
sa.push_back(a[i]);
}
sort(ALL(sa));
UNIQUE(sa);
auto get_id = [&](string &s){
auto it = lower_bound(ALL(sa), s);
if (it != sa.end() && s == *it) return (int)(it - sa.begin());
return -1;
};
rep(i, sa.size()){
auto &s = sa[i];
rep(j, s.size() - 1){
swap(s[j], s[j + 1]);
int to = get_id(s);
if (i != to && to >= 0){
G[i].insert(to);
G[to].insert(i);
}
swap(s[j], s[j + 1]);
}
}
MEMSET(col, -1);
rep(i, sa.size()) if (col[i] < 0) dfs(i, 0);
rep(i, t){
cout << col[get_id(a[i])] << '\n';
}
}
提出情報
| 提出日時 |
|
| 問題 |
F - チェックディジット |
| ユーザ |
yuusune |
| 言語 |
C++11 (GCC 4.9.2) |
| 得点 |
200 |
| コード長 |
1857 Byte |
| 結果 |
AC |
| 実行時間 |
411 ms |
| メモリ |
21144 KiB |
ジャッジ結果
| セット名 |
Subtask00 |
Subtask01 |
Subtask02 |
Subtask03 |
Subtask04 |
Subtask05 |
Subtask06 |
Subtask07 |
| 得点 / 配点 |
25 / 25 |
25 / 25 |
25 / 25 |
25 / 25 |
25 / 25 |
25 / 25 |
25 / 25 |
25 / 25 |
| 結果 |
|
|
|
|
|
|
|
|
| セット名 |
テストケース |
| Subtask00 |
00_n_3e1 |
| Subtask01 |
01_n_1e2 |
| Subtask02 |
02_n_3e2 |
| Subtask03 |
03_n_1e3 |
| Subtask04 |
04_n_3e3 |
| Subtask05 |
05_n_1e4 |
| Subtask06 |
06_n_3e4 |
| Subtask07 |
07_n_1e5 |
| ケース名 |
結果 |
実行時間 |
メモリ |
| 00_n_3e1 |
AC |
34 ms |
5844 KiB |
| 01_n_1e2 |
AC |
34 ms |
5800 KiB |
| 02_n_3e2 |
AC |
33 ms |
6044 KiB |
| 03_n_1e3 |
AC |
35 ms |
5920 KiB |
| 04_n_3e3 |
AC |
40 ms |
6172 KiB |
| 05_n_1e4 |
AC |
62 ms |
7320 KiB |
| 06_n_3e4 |
AC |
132 ms |
10140 KiB |
| 07_n_1e5 |
AC |
411 ms |
21144 KiB |
| sample |
AC |
34 ms |
5784 KiB |