목록분류 전체보기 (210)
정화 코딩
관련 패키지 (jsonwebtoken, cookie-parser) 설치npm install jsonwebtokennpm install cookie-parser --savejwt.jsimport jwt from 'jsonwebtoken';const secretKey = process.env.JWT_SECRET_KEY;// 새로운 토큰을 생성하는 함수export const generateToken = (payload) => { const token = jwt.sign(payload, secretKey, { expiresIn: '10m' }); return token;};// 기존 토큰을 사용하여 새로운 토큰을 생성하는 함수export const refreshToken = (token) => { tr..

https://www.acmicpc.net/problem/2638 #include #include #include using namespace std;int dx[] = {1, -1, 0, 0};int dy[] = {0, 0, 1, -1};int n, m;vector> g;bool bfs() { vector> vst(n, vector(m, false)); vector> out(n, vector(m, false)); bool finish = true; queue> q; q.emplace(0, 0); vst[0][0] = true; while (!q.empty()) { int curi = q.front().first; int curj = q.fr..

https://www.acmicpc.net/problem/17939 #include #include using namespace std;int n;vector c;int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n; c = vector(n); for (int i = 0; i > c[i]; int ans = 0; int s = 0; int e = c.size(); while (s = maxv) { maxv = c[i]; maxi = i; } } for (int i = s;..

https://www.acmicpc.net/problem/4673 #include using namespace std;int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); bool sn[10001]; fill_n(sn, 10001, true); for (int i = 1; i 0) { ans += tmp % 10; tmp = tmp / 10; } if (ans C++에서 초기화를 하려면 fill_n(sn, 10001, true); 이렇게 해야 한다. 끙.. 맨날 벡터만 써서 몰랐네. (정답)

#include #include #include #include using namespace std;string str;int n;string res;bool fin = false;vector a;vector chk;void dfs(int idx) { if (fin) { return; } if (idx == n) { if (res > str) { for (char c: res) { cout > str; res = str.substr(); n = str.size(); chk = vector(n); for (char c: str) { a.push_back(c - '0'); } ..

https://www.acmicpc.net/problem/1166 #include #include typedef long long ll;typedef long double ld;using namespace std;int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n, l, w, h; cin >> n >> l >> w >> h; ld li = 0; ld ri = l + 1; for (int i = 0; i 실수 이분 탐색 문제는 처음 풀어봤다. (정답)우선, 오차는 10^(-9)까지 허용한다고 하니 cout li, ri, mi 전부 실수로 정의하되, 이분 탐색 계산할 때는 정수로 계산한..

https://www.acmicpc.net/problem/5430 #include #include #include using namespace std;int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int tn; cin >> tn; while(tn--) { string func; cin >> func; int n; cin >> n; string str; cin >> str; string tmp; deque deq; for (char c: str) { if (c =..

https://www.acmicpc.net/problem/25046 #include #include #include using namespace std;int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n; cin >> n; vector> s(n, vector(n)); for (int i = 0; i > s[i][j]; } } int bm; // rows seleted by minwoo int maxi = 1 > 1; } // if jongjin select this col -> jongjin's score = on ..