# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
257933 |
2020-08-05T05:18:49 Z |
MrRobot_28 |
Datum (COCI20_datum) |
C++17 |
|
26 ms |
1664 KB |
#include<bits/stdc++.h>
using namespace std;
bool cmp(vector <int> a, vector <int> b)
{
if(a[2] != b[2])
{
return a[2] < b[2];
}
else if(a[1] != b[1])
{
return a[1] < b[1];
}
else
{
return a[0] < b[0];
}
}
signed main() {
// ios_base::sync_with_stdio(false);
// cin.tie(NULL);
// cout.tie(NULL);
int n;
cin >> n;
vector <vector <int> > a(n, vector <int> (4));
for(int i = 0; i < n; i++)
{
string s;
cin >> s;
a[i][0] = (s[0] - '0') * 10 + s[1] - '0';
a[i][1] = (s[3] - '0') * 10 + s[4] - '0';
a[i][2] = (s[6] - '0') * 1000 + (s[7] - '0') * 100 + (s[8] - '0') * 10 + (s[9] - '0');
a[i][3] = i;
}
sort(a.begin(), a.end(), cmp);
vector <vector <int> > mass;
for(int c = 0; c < 10000; c++)
{
int a = (c % 10) * 10 + (c / 10) % 10;
int b = ((c / 100) % 10) * 10 + c / 1000;
if(b > 0 && b <= 12){
if(b == 1 || b == 3 || b == 5 || b == 7 || b == 8 || b == 10 || b == 12)
{
if(a > 0 && a < 32)
{
vector <int> pu;
pu.push_back(a);
pu.push_back(b);
pu.push_back(c);
mass.push_back(pu);
}
}
else if(b == 2)
{
if(c % 400 == 0 || c % 4 == 0 && c % 100 != 0)
{
if(a > 0 && a < 30)
{vector <int> pu;
pu.push_back(a);
pu.push_back(b);
pu.push_back(c);
mass.push_back(pu);
}
}
else
{
if(a > 0 && a < 29)
{vector <int> pu;
pu.push_back(a);
pu.push_back(b);
pu.push_back(c);
mass.push_back(pu);
}
}
}
else if(a > 0 && a < 31)
{vector <int> pu;
pu.push_back(a);
pu.push_back(b);
pu.push_back(c);
mass.push_back(pu);
}
}
}
vector <vector <int> > ans(n, vector <int> (3));
int it = 0;
for(int i = 0; i < n; i++)
{
while(a[i][2] > mass[it][2] || (a[i][2] == mass[it][2] && (a[i][1] > mass[it][1] || (a[i][1] == mass[it][1] && a[i][0] >= mass[it][0]))))
{
it++;
}
ans[a[i][3]] = mass[it];
}
for(int i = 0; i < n; i++)
{
cout << ans[i][0] / 10 << ans[i][0] % 10 << ".";
cout << ans[i][1] / 10 << ans[i][1] % 10 << ".";
cout << ans[i][2] / 1000 << ans[i][2] / 100 % 10 << ans[i][2] / 10 % 10 << ans[i][2] % 10 << "\n";
}
return 0;
}
Compilation message
datum.cpp: In function 'int main()':
datum.cpp:54:35: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
if(c % 400 == 0 || c % 4 == 0 && c % 100 != 0)
~~~~~~~~~~~^~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
512 KB |
Output isn't correct |
2 |
Incorrect |
26 ms |
1664 KB |
Output isn't correct |
3 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
4 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
5 |
Incorrect |
0 ms |
384 KB |
Output isn't correct |
6 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
7 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
8 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
9 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
10 |
Incorrect |
26 ms |
1664 KB |
Output isn't correct |