๐Ÿ’  Cpp/[Solved.ac] Random Marathon

[BOJ][C++] ๋ฐฑ์ค€ 12791๋ฒˆ: Starman (Bronze I)

์„ ๋‹ฌ 2025. 1. 21. 03:49
๋ฐ˜์‘ํ˜•

๋ฌธ์ œ

2016๋…„์€ Coder's High ์˜จ์‚ฌ์ดํŠธ๊ฐ€ 2๋…„ ๋งŒ์— ๋Œ์•„์˜จ ๊ฒฝ์‚ฌ์Šค๋Ÿฌ์šด ํ•ด์ด๊ธฐ๋„ ํ•˜์ง€๋งŒ, ์ „์„ค์ ์ธ ๋ฝ ์Šคํƒ€ David Bowie๊ฐ€ ์ง€๋ณ‘์ธ ์•”์œผ๋กœ ์‚ฌ๋งํ•œ ์Šฌํ”ˆ ๋…„๋„์ด๊ธฐ๋„ ํ•˜๋‹ค.
์žฌํ˜„์ด๋Š” ๋ฐ์ด๋น— ๋ณด์œ„๋ฅผ ๊ธฐ๋ฆฌ๊ธฐ ์œ„ํ•ด์„œ, RDBMS(Rockstar David Bowie Memorial System) ๋ผ๋Š” ํ”„๋กœ๊ทธ๋žจ์„ ๊ตฌ์ƒํ•˜์˜€๋‹ค. RDBMS๋Š” SQL(Starman Query Language)๋ผ๋Š” ์–ธ์–ด๋ฅผ ํ†ตํ•ด์„œ ์ž‘๋™ํ•œ๋‹ค. SQL์€ ์ƒ๋‹นํžˆ ๊ฐ„๋‹จํ•œ ์–ธ์–ด๋กœ, ๋‹ค์Œ๊ณผ ๊ฐ™์€ ์งˆ์˜์— ๋Œ€ํ•ด์„œ ์‘๋‹ตํ•œ๋‹ค.
์žฌํ˜„์ด๋ฅผ ๋„์™€์„œ, SQL์˜ ์งˆ์˜์— ์‘๋‹ตํ•˜๋Š” ํ”„๋กœ๊ทธ๋žจ์„ ๋งŒ๋“ค์–ด๋ผ.๋ฌธ์ œ ์„ค๋ช…์— ์ฃผ์–ด์ง€์ง€ ์•Š์€ ์ •๋ณด๋กœ ์ƒ๊ธฐ๋Š” ๋ฌธ์ œ๋ฅผ ์—†์• ๊ธฐ ์œ„ํ•ด, ์˜ˆ์ œ 2๋Š” ๋ชจ๋“  ๊ฐ€๋Šฅํ•œ ๋ฐ์ด๋น— ๋ณด์œ„์˜ ์•จ๋ฒ”์„ ํฌํ•จํ•œ, ์˜ฌ๋ฐ”๋ฅธ ์ถœ๋ ฅ์„ ๋ณด์—ฌ์ค€๋‹ค. ์˜ˆ์ œ 2์˜ ๋ฐ์ดํ„ฐ๋ฅผ ๋ฐ”ํƒ•์œผ๋กœ ์ถœ๋ ฅํ•˜๋ผ.

์ž…๋ ฅ

์ฒซ ๋ฒˆ์งธ ์ค„์— ์งˆ์˜์˜ ์ˆ˜ ์ •์ˆ˜Q(Q≤ 100)๊ฐ€ ์ฃผ์–ด์ง„๋‹ค.
์ดํ›„Q๊ฐœ์˜ ์ค„์— ์งˆ์˜S,E(1 ≤S≤E≤ 2016)๊ฐ€ ์ •์ˆ˜๋กœ ์ฃผ์–ด์ง„๋‹ค.

์ถœ๋ ฅ

๊ฐ ์งˆ์˜์— ๋Œ€ํ•ด์„œ ๋‹ค์Œ ์ •๋ณด๋ฅผ ์ถœ๋ ฅํ•œ๋‹ค :
๊ฐ๊ฐ์˜ ์งˆ์˜๋งˆ๋‹ค ์ƒˆ ์ค„๋กœ ๊ตฌ๋ถ„ํ•  ํ•„์š”๋Š” ์—†๋‹ค. ์˜ˆ์ œ ์ž…์ถœ๋ ฅ์„ ์ฐธ๊ณ ํ•˜๋ผ.

 

ํ’€์ด

// ํ’€์ด : https://whkakrkr.tistory.com

#include <iostream>
#include <vector>

using namespace std;

typedef pair<int, string> ci;

const vector<ci> ALBUMS = {
{1967, "DavidBowie"},
{1969, "SpaceOddity"},
{1970, "TheManWhoSoldTheWorld"},
{1971, "HunkyDory"},
{1972, "TheRiseAndFallOfZiggyStardustAndTheSpidersFromMars"},
{1973, "AladdinSane"},
{1973, "PinUps"},
{1974, "DiamondDogs"},
{1975, "YoungAmericans"},
{1976, "StationToStation"},
{1977, "Low"},
{1977, "Heroes"},
{1979, "Lodger"},
{1980, "ScaryMonstersAndSuperCreeps"},
{1983, "LetsDance"},
{1984, "Tonight"},
{1987, "NeverLetMeDown"},
{1993, "BlackTieWhiteNoise"},
{1995, "1.Outside"},
{1997, "Earthling"},
{1999, "Hours"},
{2002, "Heathen"},
{2003, "Reality"},
{2013, "TheNextDay"},
{2016, "BlackStar"}
};

int main() {
    ios_base::sync_with_stdio(false);
	cout.tie(NULL);
	cin.tie(NULL);
	
	int q, s,e;
	cin >> q;
	while(q--) {
	    cin >> s >> e;
	    
	    vector<ci> v;
	    for(ci i : ALBUMS) {
	        if(s<=i.first && i.first<=e) {
	            v.push_back(i);
	        }
	    }
	    
	    cout << v.size() << "\n";
	    for(ci i : v) {
	        cout << i.first << " " << i.second << "\n";
	    }
	}
	
    return 0;
}
๋ฐ˜์‘ํ˜•