[SWEA] 1234 비밀번호

Time Lapse :3min 0sec

1234.cpp

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#include <cstdio>
#define gc() getchar_unlocked()
#define pc(x) putchar_unlocked(x)
#define ADD3(a,b,c) ((a)+(b)+(c))
using namespace std;

inline int fRI(){
int N=gc(), ret = 0;
for(;N<'0'||N>'9';N=gc());
do{
ret = ADD3((ret<<3),(ret<<1),(N&0b1111)); N = gc();
}while('0'<=N&&N<='9');
return ret-1;
}
inline void fWA(int tc) {
int r = 0, c = 0;
pc(0x23);
while (!(tc % 10)) { c++; tc /= 10; }
while (tc) { r = ADD3((r << 3), (r << 1), tc % 10); tc /= 10; }
while (r) { pc(r % 10 | 0b110000); r /= 10; }
while (c--) pc(0x30); pc(0x20);
}

int main(int argc, char **argv) {
register int tc = 1, len, idx;
char buf[100];
for (; tc <= 10;) {
len = fRI(); idx = 1;
buf[0] = gc();
while(len--){
buf[idx] = gc();
if(!(buf[idx]^buf[idx-1])) idx -=2;
idx++;
}
fWA(tc++);
len = 0;
while(len^idx) pc(buf[len++]);
pc(0x0A);
}
}
Author: Song Hayoung
Link: https://songhayoung.github.io/2020/08/04/PS/SWEA/1234/
Copyright Notice: All articles in this blog are licensed under CC BY-NC-SA 4.0 unless stating additionally.