QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#781142 | #4068. Distinctive Character | songszh | AC ✓ | 277ms | 192736kb | C++14 | 3.5kb | 2024-11-25 14:55:45 | 2024-11-25 14:55:46 |
Judging History
answer
#include <bits/stdc++.h>
// #define int long long
#define ll long long
#define ull unsigned long long
#define db double
#define ld long double
#define rep(i,l,r) for (int i = (int)(l); i <= (int)(r); ++ i )
#define rep1(i,l,r) for (int i = (int)(l); i >= (int)(r); -- i )
#define il inline
#define fst first
#define snd second
#define ptc putchar
#define Yes ptc('Y'),ptc('e'),ptc('s'),puts("")
#define No ptc('N'),ptc('o'),puts("")
#define YES ptc('Y'),ptc('E'),ptc('S'),puts("")
#define NO ptc('N'),ptc('O'),puts("")
#define vi vector<int>
#define pb emplace_back
#define sz(x) (int)(x.size())
#define all(x) x.begin(),x.end()
#define me(a,x) memset(a,x,sizeof a)
#define get(x) ((x - 1) / len + 1)
#define debug() puts("------------")
using namespace std;
typedef pair<int,int> PII;
typedef pair<int,PII> PIII;
typedef pair<ll,ll> PLL;
namespace szhqwq {
template<class T> il void read(T &x) {
x = 0; T f = 1; char ch = getchar();
while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); }
while (ch >= '0' && ch <= '9') { x = (x << 3) + (x << 1) + (ch ^ 48); ch = getchar(); }
x *= f;
}
template<class T,class... Args> il void read(T &x,Args &...x_) { read(x); read(x_...); }
template<class T> il void print(T x) {
if (x < 0) ptc('-'), x = -x;
if (x > 9) print(x / 10); ptc(x % 10 + '0');
}
template<class T,class T_> il void write(T x,T_ ch) { print(x); ptc(ch); }
template<class T,class T_> il void chmax(T &x,T_ y) { x = x < (T)y ? (T)y : x; }
template<class T,class T_> il void chmin(T &x,T_ y) { x = x > (T)y ? (T)y : x; }
template<class T,class T_,class T__> il T qmi(T a,T_ b,T__ p) {
T res = 1; while (b) {
if (b & 1) res = res * a % p;
a = a * a % p; b >>= 1;
} return res;
}
template<class T> il T gcd(T a,T b) { if (!b) return a; return gcd(b,a % b); }
template<class T,class T_> il void exgcd(T a, T b, T_ &x, T_ &y) {
if (b == 0) { x = 1; y = 0; return; }
exgcd(b,a % b,y,x); y -= a / b * x; return ;
}
template<class T,class T_> il T getinv(T x,T_ p) {
T inv,y; exgcd(x,(T)p,inv,y);
inv = (inv + p) % p; return inv;
}
} using namespace szhqwq;
const int N = 2e6 + 10,inf = 1e9,mod = 998244353;
const ull base = 131,base_ = 233;
const ll inff = 1e18;
const db eps = 1e-6;
int n,k,a[N]; bool vis[N];
int h[N],e[N * 20],ne[N * 20],idx;
int dist[N];
il void add(int a,int b) {
e[idx] = b;
ne[idx] = h[a];
h[a] = idx ++;
}
il void bfs() {
queue<int> q; me(dist,0x3f);
rep(i,1,n) q.push(a[i]),vis[a[i]] = 1,dist[a[i]] = 0;
while (sz(q)) {
int u = q.front(); q.pop();
for (int i = h[u]; ~i; i = ne[i]) {
int j = e[i];
if (dist[j] > dist[u] + 1) {
dist[j] = dist[u] + 1;
if (!vis[j]) vis[j] = 1,q.push(j);
}
}
}
return ;
}
il void solve() {
//------------code------------
read(n,k); me(h,-1);
rep(i,1,n) {
string s; cin >> s;
rep(j,0,k - 1) a[i] += (1 << j) * (s[j] - '0');
}
rep(s,0,(1 << k) - 1)
rep(p,0,k - 1) add(s,s ^ (1 << p));
bfs();
int ret = 0,mx = 0;
rep(s,0,(1 << k) - 1) if (dist[s] > mx) mx = dist[s],ret = s;
rep(p,0,k - 1) cout << (ret >> p & 1); puts("");
return ;
}
il void init() {
return ;
}
signed main() {
// init();
int _ = 1;
// read(_);
while (_ -- ) solve();
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 23700kb
input:
3 5 01001 11100 10111
output:
00010
result:
ok
Test #2:
score: 0
Accepted
time: 2ms
memory: 23708kb
input:
1 4 0000
output:
1111
result:
ok
Test #3:
score: 0
Accepted
time: 0ms
memory: 21884kb
input:
1 1 0
output:
1
result:
ok
Test #4:
score: 0
Accepted
time: 0ms
memory: 23696kb
input:
1 2 01
output:
10
result:
ok
Test #5:
score: 0
Accepted
time: 0ms
memory: 23668kb
input:
1 5 00100
output:
11011
result:
ok
Test #6:
score: 0
Accepted
time: 99ms
memory: 188264kb
input:
1 20 00100000111011111010
output:
11011111000100000101
result:
ok
Test #7:
score: 0
Accepted
time: 0ms
memory: 21628kb
input:
2 1 1 0
output:
0
result:
ok
Test #8:
score: 0
Accepted
time: 5ms
memory: 23900kb
input:
2 2 10 01
output:
00
result:
ok
Test #9:
score: 0
Accepted
time: 0ms
memory: 23700kb
input:
2 5 00010 00100
output:
11001
result:
ok
Test #10:
score: 0
Accepted
time: 133ms
memory: 190292kb
input:
2 20 11110100100011011100 11110000000000110111
output:
00001111011100000000
result:
ok
Test #11:
score: 0
Accepted
time: 0ms
memory: 23868kb
input:
100 1 0 1 1 1 0 0 0 1 1 1 0 1 1 1 1 0 1 1 0 0 1 0 0 1 0 1 0 1 1 0 0 1 1 1 0 0 0 1 0 1 1 0 1 1 0 0 0 0 1 1 1 1 1 1 1 1 0 1 1 1 0 0 1 1 0 0 1 0 0 0 0 1 1 1 1 0 0 0 0 0 1 0 0 1 0 0 1 1 1 1 1 0 0 1 1 1 1 0 1 0
output:
0
result:
ok
Test #12:
score: 0
Accepted
time: 0ms
memory: 21544kb
input:
100 2 01 10 11 01 11 10 10 10 00 01 11 00 00 11 11 00 01 01 01 11 10 11 10 11 01 11 01 00 11 10 01 00 01 11 10 11 11 11 01 00 11 00 10 11 10 10 11 00 11 00 11 11 10 00 11 10 00 01 11 01 10 10 11 11 10 00 01 11 01 11 10 10 11 10 00 10 11 00 01 10 11 00 10 00 11 01 01 11 11 01 10 11 00 10 10 00 10 01 ...
output:
00
result:
ok
Test #13:
score: 0
Accepted
time: 0ms
memory: 23592kb
input:
100 5 10010 00111 11100 01100 11010 01110 11111 11101 11000 01110 00011 00001 11110 10011 10001 11011 00010 11000 10000 01101 10101 00010 11100 11000 01000 01000 00110 10011 10100 01100 10011 01000 01110 00110 00011 10111 10001 10110 11000 00101 11010 01100 11011 11011 11010 10111 01010 10010 00111 ...
output:
01111
result:
ok
Test #14:
score: 0
Accepted
time: 181ms
memory: 189156kb
input:
100 20 00110011101000101001 11111100011011011101 00101010010111100001 01010010011000010110 11000010001101110111 00010001010000101101 10110010110010111101 11101111110011100101 11111010001001111111 10011011000111001101 11011000110101101000 01110010110011100111 01111001010000101110 11100010010110111111...
output:
10001001001001010000
result:
ok
Test #15:
score: 0
Accepted
time: 0ms
memory: 23956kb
input:
1000 1 0 1 1 0 1 0 0 0 1 0 0 1 0 1 1 1 1 1 1 0 0 0 1 0 1 1 1 0 0 1 0 0 1 1 0 1 0 0 0 0 1 0 1 1 0 0 0 1 0 0 0 1 1 1 0 1 1 1 0 1 0 1 1 0 0 0 1 0 1 1 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 1 0 1 1 1 0 0 0 0 0 1 0 1 1 0 1 1 1 0 1 1 0 1 1 1 0 0 1 1 0 1 0 0 1 1 0 1 0 0 0 0 1 0 1 1 0 0 1 1 1 0 1 0 0 0 1 0 0 1 0...
output:
0
result:
ok
Test #16:
score: 0
Accepted
time: 4ms
memory: 21600kb
input:
1000 2 10 01 00 11 10 01 10 11 00 10 10 10 01 01 11 11 00 11 00 01 00 10 11 01 00 01 00 11 00 00 01 11 00 00 11 10 10 11 00 00 11 00 00 11 01 00 00 01 10 11 10 11 11 10 00 10 10 11 01 01 01 11 11 10 01 01 11 11 11 11 11 11 00 11 01 11 01 10 11 11 00 11 00 01 10 00 00 10 01 00 11 10 11 11 00 00 11 10...
output:
00
result:
ok
Test #17:
score: 0
Accepted
time: 0ms
memory: 23684kb
input:
1000 5 01101 00000 00110 01001 10100 01001 01110 00011 00111 01000 10000 01110 01100 00101 01101 00100 00001 01011 10000 01110 10111 10001 00001 11101 00011 11110 00100 11110 00010 11111 00101 00100 01001 11110 11000 01100 01110 11101 00111 00000 10100 11011 00001 00101 11010 00010 11010 00101 11101...
output:
00000
result:
ok
Test #18:
score: 0
Accepted
time: 188ms
memory: 190092kb
input:
1000 20 10010101010110101110 00001110001111100101 01100101111110000001 11011001011100011110 10010011111001010000 00010100100000100011 00100101000000101101 10110001001110011101 10010111111011011000 11011000010011011011 00100111100010101111 11010111110111111101 01000110010110110101 0010001110010001001...
output:
11000100000000000000
result:
ok
Test #19:
score: 0
Accepted
time: 7ms
memory: 24164kb
input:
100000 1 1 1 1 1 0 0 0 0 0 0 0 0 1 0 1 0 0 1 1 1 0 1 1 0 1 1 1 0 1 0 1 1 1 1 1 0 0 0 1 1 0 1 0 0 0 1 1 1 0 1 1 0 1 0 0 1 0 0 1 0 0 1 0 0 1 1 1 0 0 0 1 0 1 1 0 1 1 0 1 0 1 0 1 0 0 1 1 1 1 0 1 1 0 0 1 1 1 1 1 0 0 1 0 0 1 1 0 0 0 0 1 1 1 1 1 0 0 0 1 1 1 1 1 1 0 0 1 0 1 0 1 0 0 1 0 0 1 1 1 1 1 1 0 0 1 1...
output:
0
result:
ok
Test #20:
score: 0
Accepted
time: 9ms
memory: 24468kb
input:
100000 2 00 00 01 01 10 00 01 10 00 00 00 00 10 11 00 10 01 10 10 11 00 10 10 00 10 01 10 01 00 11 01 10 01 11 10 11 00 01 11 11 01 10 00 01 00 11 00 10 01 01 00 11 01 01 11 10 11 01 01 00 11 11 01 10 01 00 01 10 01 10 10 10 11 11 10 00 00 01 01 00 01 01 01 11 01 10 11 01 10 00 10 01 00 01 11 00 00 ...
output:
00
result:
ok
Test #21:
score: 0
Accepted
time: 12ms
memory: 22176kb
input:
100000 5 10110 10000 00110 10111 11011 00101 11100 10111 11001 10101 00011 11001 00101 00010 10011 00110 00111 00010 10111 10000 11000 10000 00010 01111 11101 10010 11101 11010 10010 10111 10001 10010 10111 10101 11111 11110 00010 10010 10000 11101 11101 10110 10111 11110 10010 01000 01000 10111 001...
output:
00000
result:
ok
Test #22:
score: 0
Accepted
time: 259ms
memory: 192736kb
input:
100000 20 00010100001101110001 00011111101100000111 11111101101111100110 00110100100100001010 01101010010100000001 00011100000101001101 01110010100110000001 11110011101010011100 11011100010011110011 01101010011110111101 10011111101011010111 00100000010001101100 10111010101001011001 10011000101000100...
output:
00100000000000000000
result:
ok
Test #23:
score: 0
Accepted
time: 277ms
memory: 191344kb
input:
99973 20 11000111000011101101 00101101011110011100 11001101000001011110 10001110100000001011 11010111110010111010 10000011000101000010 01001010001111101100 00111101100111101100 10111111101111111101 10000111000011100101 01110100000110010111 10111000010011000010 00001001110010110110 111011010010111011...
output:
01110011111000010011
result:
ok
Test #24:
score: 0
Accepted
time: 216ms
memory: 190988kb
input:
9988 20 11000111000011101101 00101101011110011100 11001101000001011110 10001110100000001011 11010111110010111010 10000011000101000010 01001010001111101100 00111101100111101100 10111111101111111101 10000111000011100101 01110100000110010111 10111000010011000010 00001001110010110110 1110110100101110111...
output:
01110011111000010011
result:
ok
Test #25:
score: 0
Accepted
time: 213ms
memory: 190284kb
input:
981 20 11000111000011101101 00101101011110011100 11001101000001011110 10001110100000001011 11010111110010111010 10000011000101000010 01001010001111101100 00111101100111101100 10111111101111111101 10000111000011100101 01110100000110010111 10111000010011000010 00001001110010110110 11101101001011101111...
output:
01110011111000010011
result:
ok
Test #26:
score: 0
Accepted
time: 195ms
memory: 191372kb
input:
467 20 11000111000011101101 00101101011110011100 11001101000001011110 10001110100000001011 11010111110010111010 10000011000101000010 01001010001111101100 00111101100111101100 10111111101111111101 10000111000011100101 01110100000110010111 10111000010011000010 00001001110010110110 11101101001011101111...
output:
01110011111000010011
result:
ok
Test #27:
score: 0
Accepted
time: 180ms
memory: 189196kb
input:
172 20 11000111000011101101 00101101011110011100 11001101000001011110 10001110100000001011 11010111110010111010 10000011000101000010 01001010001111101100 00111101100111101100 10111111101111111101 10000111000011100101 01110100000110010111 10111000010011000010 00001001110010110110 11101101001011101111...
output:
01110011111000010011
result:
ok
Test #28:
score: 0
Accepted
time: 148ms
memory: 189352kb
input:
100000 20 00011111010010111110 00011111010010111110 00011111010010111110 00011111010010111110 00011111010010111110 00011111010010111110 00011111010010111110 00011111010010111110 00011111010010111110 00011111010010111110 00011111010010111110 00011111010010111110 00011111010010111110 00011111010010111...
output:
11100000101101000001
result:
ok