[BOJ] 10836 여왕벌

Time Lapse :38min 30sec

10836.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 <iostream>
#define pc(x) putchar_unlocked(x)
#define gc() getchar_unlocked()
using namespace std;
int increment[1399];
int n, d, z, o;
int fri(){
int N = gc(), ret = 0;
do{
ret = (ret<<3) + (ret<<1) + (N & 0b1111); N=gc();
}while('0'<=N&&N<='9');
return ret;
}
inline void fri (int n){
if (n == 0) { pc('0'); pc(' '); return ;}
if (n<0) { n = -n; pc('-');}
int N = n, rev, count = 0;
rev = N;
while ((rev % 10) == 0) { count++; rev /= 10;} //obtain the count of the number of 0s
rev = 0;
while (N != 0) { rev = (rev<<3) + (rev<<1) + N % 10; N /= 10;} //store reverse of N in rev
while (rev != 0) { pc(rev % 10 | 0b110000); rev /= 10;}
while (count--) pc('0');
pc(' ');
}
int main() {
n = fri(), d = fri();
for(int k = 0; k < d; k++){
z = fri(), o = fri(), fri();
increment[z]++;
increment[z + o]++;
}
for(int i = 1; i < 2 * n + 1; i++)
increment[i] += increment[i-1];
for(int i = 0; i < n; i++) {
for (int j = 0; j < n; j++)
fri(!j ? increment[n - i - 1] + 1 : increment[n + j - 1] + 1);
pc('\n');
}
}
Author: Song Hayoung
Link: https://songhayoung.github.io/2020/09/07/PS/BOJ/10836/
Copyright Notice: All articles in this blog are licensed under CC BY-NC-SA 4.0 unless stating additionally.