티스토리 뷰
https://www.acmicpc.net/problem/11723
11723번: 집합
첫째 줄에 수행해야 하는 연산의 수 M (1 ≤ M ≤ 3,000,000)이 주어진다. 둘째 줄부터 M개의 줄에 수행해야 하는 연산이 한 줄에 하나씩 주어진다.
www.acmicpc.net
Node로 못 푸는 문제.😥
Node.js 로 풀려고 했는데 이 문제 Node로 푼 사람이 없다.
전부 메모리 초과다.
어쩔 수 없이 C로 풀었다.
#include <stdio.h>
#include <string.h>
int main(void){
int n;
scanf("%d",&n);
int num[21];
for(int i = 0; i<=20; i++){
num[i] = 0;
}
for(int i = 0; i<n; i++){
char s[10];
scanf("%s",s);
int x;
if(strcmp(s,"add")==0){
scanf("%d",&x);
num[x] = 1;
}else if(strcmp(s,"remove")==0){
scanf("%d",&x);
num[x] = 0;
}else if(strcmp(s,"check")==0){
scanf("%d",&x);
if(num[x] == 1){
printf("1\n");
}else{
printf("0\n");
}
}else if(strcmp(s,"toggle")==0){
scanf("%d",&x);
num[x] = !num[x];
}else if(strcmp(s,"all")==0){
for(int i = 1; i<=20; i++){
num[i] = 1;
}
}else if(strcmp(s,"empty")==0){
for(int i = 1; i<=20; i++){
num[i] = 0;
}
}
}
return 0;
}
728x90
'자료구조 알고리즘 > 백준' 카테고리의 다른 글
Node.js)백준 15658번: 연산자 끼워넣기 (2) (0) | 2022.01.05 |
---|---|
Node.js)백준 9093번: 단어 뒤집기 (0) | 2022.01.05 |
Node.js)백준 14391번: 종이조각 (0) | 2022.01.05 |
Node.js)백준 10971번: 외판원 순회 2 (0) | 2022.01.05 |
Node.js)백준 10819번: 차이를 최대로 (1) | 2022.01.05 |
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
링크
TAG
- create databases;
- 롱베케이션
- 그래프
- 투포인터 연습
- 면접비
- MOD
- 로드나인
- node.js
- 은둔청년체험
- 서버개발
- 서버점검
- 최소공통조상
- MySQL
- KMP
- 면접질문
- create db
- 개발자면접
- 다이나밍프로그래밍
- 투포인터
- BFS
- DB 생성
- 동적프로그래밍
- 다이나믹프로그래밍
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
글 보관함