코드포스 후기 #1
Codeforces Round #366 (Div. 2) 2016/08/07(일) 23:05
생각만 했던 코드포스 첫 참가의 기록
A. Hulk
단순 문자열 출력 문제
StringBuilder를 사용했는데 굳이 그렇게 안하고 바로바로 print를 계속해도 됐겠구나 싶다.
[소스보기 (Java)] [접기]
import java.io.BufferedReader;
import java.io.InputStreamReader;
public class Hulk {
public static String hateStr = "I hate it";
public static String loveStr = "I love it";
public static void main(String[] args) throws Exception {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int n = Integer.parseInt(br.readLine());
StringBuilder sb = new StringBuilder();
sb.append(hateStr);
for (int i = 2; i <= n; i++) {
sb.delete(sb.length() - 2, sb.length());
sb.append("that ");
if (i % 2 == 0) {
sb.append(loveStr);
} else {
sb.append(hateStr);
}
}
System.out.println(sb.toString());
}
}
[접기]
B. Spider Man
첫 도전이라 그런지 어이없게도 런타임 에러를 내버렸다 OTL
왜냐면 이클립스에서 코드 그대로 복붙했다가 잘못해서 패키지 선언을 해버려서... 하여간 아까운 감점이다.
[소스보기 (Java)] [접기]
import java.io.BufferedReader;
import java.io.InputStreamReader;
public class SpiderMan {
public static void main(String[] args) throws Exception {
BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
int n = Integer.parseInt(bf.readLine());
String[] temp = bf.readLine().split(" ");
int res = 0;
for (int i = 0; i < n; i++) {
res = (res + Integer.parseInt(temp[i]) - 1) % 2;
if (res == 0) {
System.out.println(2);
} else {
System.out.println(1);
}
}
}
}
[접기]
C. Thor
처음에 Java로 짰는데 입력을 Scanner로 받았다가 TLE가 나서 BufferedReader로 바꿨는데도 TLE가 났다 -_-
아무리 이것저것 고쳐봐도 TLE의 늪을 빠져나올 수가 없어서 화가나서 C++코드로 바꿔서 제출했더니 통과했다...
게다가 cin/cout을 사용했는데 통과함! C++로 했는데도 거의 간당간당하게 통과하느냐고 물어봤더니 scanf/printf 안쓰고 cin/cout 써서 그렇다고...
구동시간을 비교정리해보자면,
Java (BufferedReader) → TLE (2000ms+) C++ (cin/cout) → 1762ms C++ (scanf/cout) → 966ms C++ (scanf/printf) → 218ms 아무튼 이 문제 때문에 제출 8번만에 맞아서 점수가 아주 너덜너덜해졌다.
pretest 통과 성공한 시각이 첫 제출 시각 한시간 뒤라서 문제푼 시간으로 주는 점수도 낮아지고 7번의 실패로 -50*7... (털썩)
[소스보기 (Java)] [접기]
#include <cstdio>
#include <iostream>
using namespace std;
int notiMin[300001];
int notiMax[300001];
int notiCnt[300001];
int qorder[300001];
int main() {
int n, q;
scanf("%d", &n);
scanf("%d", &q);
int qsize = 0;
int total = 0;
int tmax = 0;
for (int i=1; i<=q; i++) {
int type, x, t;
scanf("%d", &type);
if (type == 1) {
scanf("%d", &x);
notiMax[x] = qsize;
notiCnt[x]++;
qorder[qsize++] = x;
total += 1;
} else if (type == 2) {
scanf("%d", &x);
notiMin[x] = notiMax[x]+1;
total -= notiCnt[x];
notiCnt[x] = 0;
} else {
scanf("%d", &t);
if (t > tmax) {
for (int j=tmax; j<t; j++) {
int checkApp = qorder[j];
if (j >= notiMin[checkApp]) {
notiMin[checkApp] = j+1;
notiCnt[checkApp] -= 1;
total -= 1;
}
}
tmax = t;
}
}
printf("%d\n", total);
}
return 0;
}
[접기]
D. Ant Man
미제출
E. Black Widow
미제출
Final Standings
Rank
Points
Extras
A
500
B
1000
C
1500
D
2250
E
2250
1091
1882
-
488
00:06
850
00:25
544
01:41
C번을 풀었는데 B번보다 적은 점수를 얻다니...
뭐 위아래로 보니 나랑 비슷한 사람들이 있어서 위안이 된다(?)
Rating Changes
Rank
Points
Rating
1091
1882
1500 → 1535 (+35)
Became Specialist
어쨌거나 첫 도전에 Specialist 가 되었다
BOJ에 아이디 색깔 등록함!
※ 링크 : 대회공지 / 출제자해설