Submission #238417

# Submission time Handle Problem Language Result Execution time Memory
238417 2020-06-11T07:15:04 Z MishoKostov Datum (COCI20_datum) C++14
50 / 50
385 ms 500 KB
#include<bits/stdc++.h>
#define endl "\n"

using namespace std;

int day[16]={31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
/*10.10.101
20.10.102
30.10.103
1.10.110
11.10.111
21.10.112
31.10.113
2.10.120
12.10.121
22.10.122
3.10.130
13.10.131
23.10.132
4.10.140
14.10.141
24.10.142
5.10.150
15.10.151
25.10.152
6.10.160
16.10.161
26.10.162
7.10.170
17.10.171
27.10.172
8.10.180
18.10.181
28.10.182
9.10.190
19.10.191
29.10.192
10.1.1001
20.1.1002
30.1.1003
1.1.1010
11.1.1011
21.1.1012
31.1.1013
2.1.1020
12.1.1021
22.1.1022
3.1.1030
13.1.1031
23.1.1032
4.1.1040
14.1.1041
24.1.1042
5.1.1050
15.1.1051
25.1.1052
6.1.1060
16.1.1061
26.1.1062
7.1.1070
17.1.1071
27.1.1072
8.1.1080
18.1.1081
28.1.1082
9.1.1090
19.1.1091
29.1.1092
10.11.1101
20.11.1102
30.11.1103
1.11.1110
11.11.1111
21.11.1112
2.11.1120
12.11.1121
22.11.1122
3.11.1130
13.11.1131
23.11.1132
4.11.1140
14.11.1141
24.11.1142
5.11.1150
15.11.1151
25.11.1152
6.11.1160
16.11.1161
26.11.1162
7.11.1170
17.11.1171
27.11.1172
8.11.1180
18.11.1181
28.11.1182
9.11.1190
19.11.1191
29.11.1192
10.2.2001
20.2.2002
1.2.2010
11.2.2011
21.2.2012
2.2.2020
12.2.2021
22.2.2022
3.2.2030
13.2.2031
23.2.2032
4.2.2040
14.2.2041
24.2.2042
5.2.2050
15.2.2051
25.2.2052
6.2.2060
16.2.2061
26.2.2062
7.2.2070
17.2.2071
27.2.2072
8.2.2080
18.2.2081
28.2.2082
9.2.2090
19.2.2091
29.2.2092
10.12.2101
20.12.2102
30.12.2103
1.12.2110
11.12.2111
21.12.2112
31.12.2113
2.12.2120
12.12.2121
22.12.2122
3.12.2130
13.12.2131
23.12.2132
4.12.2140
14.12.2141
24.12.2142
5.12.2150
15.12.2151
25.12.2152
6.12.2160
16.12.2161
26.12.2162
7.12.2170
17.12.2171
27.12.2172
8.12.2180
18.12.2181
28.12.2182
9.12.2190
19.12.2191
29.12.2192
10.3.3001
20.3.3002
30.3.3003
1.3.3010
11.3.3011
21.3.3012
31.3.3013
2.3.3020
12.3.3021
22.3.3022
3.3.3030
13.3.3031
23.3.3032
4.3.3040
14.3.3041
24.3.3042
5.3.3050
15.3.3051
25.3.3052
6.3.3060
16.3.3061
26.3.3062
7.3.3070
17.3.3071
27.3.3072
8.3.3080
18.3.3081
28.3.3082
9.3.3090
19.3.3091
29.3.3092
10.4.4001
20.4.4002
30.4.4003
1.4.4010
11.4.4011
21.4.4012
2.4.4020
12.4.4021
22.4.4022
3.4.4030
13.4.4031
23.4.4032
4.4.4040
14.4.4041
24.4.4042
5.4.4050
15.4.4051
25.4.4052
6.4.4060
16.4.4061
26.4.4062
7.4.4070
17.4.4071
27.4.4072
8.4.4080
18.4.4081
28.4.4082
9.4.4090
19.4.4091
29.4.4092
10.5.5001
20.5.5002
30.5.5003
1.5.5010
11.5.5011
21.5.5012
31.5.5013
2.5.5020
12.5.5021
22.5.5022
3.5.5030
13.5.5031
23.5.5032
4.5.5040
14.5.5041
24.5.5042
5.5.5050
15.5.5051
25.5.5052
6.5.5060
16.5.5061
26.5.5062
7.5.5070
17.5.5071
27.5.5072
8.5.5080
18.5.5081
28.5.5082
9.5.5090
19.5.5091
29.5.5092
10.6.6001
20.6.6002
30.6.6003
1.6.6010
11.6.6011
21.6.6012
2.6.6020
12.6.6021
22.6.6022
3.6.6030
13.6.6031
23.6.6032
4.6.6040
14.6.6041
24.6.6042
5.6.6050
15.6.6051
25.6.6052
6.6.6060
16.6.6061
26.6.6062
7.6.6070
17.6.6071
27.6.6072
8.6.6080
18.6.6081
28.6.6082
9.6.6090
19.6.6091
29.6.6092
10.7.7001
20.7.7002
30.7.7003
1.7.7010
11.7.7011
21.7.7012
31.7.7013
2.7.7020
12.7.7021
22.7.7022
3.7.7030
13.7.7031
23.7.7032
4.7.7040
14.7.7041
24.7.7042
5.7.7050
15.7.7051
25.7.7052
6.7.7060
16.7.7061
26.7.7062
7.7.7070
17.7.7071
27.7.7072
8.7.7080
18.7.7081
28.7.7082
9.7.7090
19.7.7091
29.7.7092
10.8.8001
20.8.8002
30.8.8003
1.8.8010
11.8.8011
21.8.8012
31.8.8013
2.8.8020
12.8.8021
22.8.8022
3.8.8030
13.8.8031
23.8.8032
4.8.8040
14.8.8041
24.8.8042
5.8.8050
15.8.8051
25.8.8052
6.8.8060
16.8.8061
26.8.8062
7.8.8070
17.8.8071
27.8.8072
8.8.8080
18.8.8081
28.8.8082
9.8.8090
19.8.8091
29.8.8092
10.9.9001
20.9.9002
30.9.9003
1.9.9010
11.9.9011
21.9.9012
2.9.9020
12.9.9021
22.9.9022
3.9.9030
13.9.9031
23.9.9032
4.9.9040
14.9.9041
24.9.9042
5.9.9050
15.9.9051
25.9.9052
6.9.9060
16.9.9061
26.9.9062
7.9.9070
17.9.9071
27.9.9072
8.9.9080
18.9.9081
28.9.9082
9.9.9090
19.9.9091
29.9.9092*/

string check(int a, int b, int c)
{
    //cout<<a%100<<" "<<c%10<<" "<<a%10<<" "<<c%100<<" "<<b%100<<" "<<c%1000<<" "<<b%10<<" "<<c%10000<<endl;
    //cout<<c%10<<" "<<c%100<<" "<<c%1000<<" "<<c%10000<<endl;
    string s="";
    if(a<10) s+="0", s+=a+'0';
    else s+=a/10%10+'0', s+=a%10+'0';
    s+=".";
    if(b<10) s+="0", s+=b+'0';
    else s+=b/10%10+'0', s+=b%10+'0';
    s+=".";
    if(c<10) s+="000", s+=c+'0';
    else if(c<100) s+="00", s+=c/10%10+'0', s+=c%10+'0';
    else if(c<1000) s+="0", s+=c/100%10+'0', s+=c/10%10+'0', s+=c%10+'0';
    else s+=c/1000%10+'0', s+=c/100%10+'0', s+=c/10%10+'0', s+=c%10+'0';
    //cout<<s<<endl;
    if(s[0]==s[9]&&s[1]==s[8]&&s[3]==s[7]&&s[4]==s[6]) return s;
    return "0";
}

bool cons(string a, string b)
{
    int y1=(a[9]-'0')+(a[8]-'0')*10+(a[7]-'0')*100+(a[6]-'0')*1000;
    int y2=(b[9]-'0')+(b[8]-'0')*10+(b[7]-'0')*100+(b[6]-'0')*1000;
    if(y2>y1) return true;
    if(y2<y1) return false;
    int m1=(a[4]-'0')+(a[3]-'0')*10;
    int m2=(b[4]-'0')+(b[3]-'0')*10;
    if(m2>m1) return true;
    if(m2<m1) return false;
    int d1=(a[1]-'0')+(a[0]-'0')*10;
    int d2=(b[1]-'0')+(b[0]-'0')*10;
    if(d2>d1) return true;
    else return false;
}

int main()
{
	//ios_base::sync_with_stdio(false);
	//cin.tie(NULL);
	//cout.tie(NULL);

	const int nmax=512;
	string v[nmax];
	int p=0;
	for(int i=0; i<=9999; ++i)
    {
        for(int j=1; j<=12; ++j)
        {
            int s;
            if(j==2&&i%4==0) s=29;
            else s=day[j-1];
            for(int k=1; k<=s; ++k)
            {
                //cout<<k<<" "<<j<<" "<<i<<endl;
                string d=check(k, j, i);
                if(d!="0") v[p]=d, p++;
            }
        }
    }
    int n;
    string d;
    cin>>n;
    for(int i=0; i<n; ++i)
    {
        cin>>d;
        for(int j=0; j<p; ++j)
        {
            //cout<<v[j]<<endl;
            if(cons(d, v[j]))
            {
                cout<<v[j]<<"."<<endl;
                break;
            }
        }
    }
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 307 ms 376 KB Output is correct
2 Correct 382 ms 376 KB Output is correct
3 Correct 309 ms 376 KB Output is correct
4 Correct 309 ms 376 KB Output is correct
5 Correct 306 ms 376 KB Output is correct
6 Correct 309 ms 380 KB Output is correct
7 Correct 299 ms 376 KB Output is correct
8 Correct 308 ms 376 KB Output is correct
9 Correct 311 ms 376 KB Output is correct
10 Correct 385 ms 500 KB Output is correct