답안 #570428

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
570428 2022-05-29T19:31:52 Z NekoRolly Datum (COCI20_datum) C++17
50 / 50
5 ms 340 KB
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 2e3+4;

struct fecha{
	int d,m,a;
};

bool operator<(fecha a,fecha b){
	return (a.a != b.a ? a.a < b.a : a.m != b.m ? a.m < b.m : a.d < b.d);
}

int q;
string s;
int days[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
vector<fecha> v;

void read(int &x){ x = 0;
	for (char c=getchar(); '0'<=c && c<='9'; c = getchar())
		x = x*10 + (c - '0');
}

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

	for (int d1=0; d1<=9; d1++) for (int d2=0; d2<=9; d2++)
		for (int d3=0; d3<=9; d3++) for (int d4=0; d4<=9; d4++){
			int d = d4*10 + d3, m = d2*10 + d1, a = d1*1000 + d2*100 + d3*10 + d4;
			if (0 < m && m < 13 && 0 < d && d <= days[m] + (a%4 == 0 && m == 2))
				v.push_back({d, m, a});
		}

	read(q);

	for (fecha x; q; q--){ read(x.d), read(x.m), read(x.a); getchar();
		int i = 0;
		while (!(x < v[i])) i++;
		if (v[i].d < 10) cout << "0"; cout << v[i].d << ".";
		if (v[i].m < 10) cout << "0"; cout << v[i].m << ".";
		if (v[i].a < 10) cout << "000";
		if (v[i].a < 100) cout << "00";
		if (v[i].a < 1000) cout << "0"; cout << v[i].a << ".\n";
	}

    return 0;
}

Compilation message

datum.cpp: In function 'int main()':
datum.cpp:39:3: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   39 |   if (v[i].d < 10) cout << "0"; cout << v[i].d << ".";
      |   ^~
datum.cpp:39:33: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   39 |   if (v[i].d < 10) cout << "0"; cout << v[i].d << ".";
      |                                 ^~~~
datum.cpp:40:3: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   40 |   if (v[i].m < 10) cout << "0"; cout << v[i].m << ".";
      |   ^~
datum.cpp:40:33: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   40 |   if (v[i].m < 10) cout << "0"; cout << v[i].m << ".";
      |                                 ^~~~
datum.cpp:43:3: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   43 |   if (v[i].a < 1000) cout << "0"; cout << v[i].a << ".\n";
      |   ^~
datum.cpp:43:35: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   43 |   if (v[i].a < 1000) cout << "0"; cout << v[i].a << ".\n";
      |                                   ^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 5 ms 340 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 5 ms 340 KB Output is correct