Submission #346005

#TimeUsernameProblemLanguageResultExecution timeMemory
346005Pichon5Datum (COCI20_datum)C++17
35 / 50
137 ms748 KiB
#include<bits/stdc++.h> #define lcm(a,b) (a/__gcd(a,b))*b #define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); #define ll long long int #define vi vector<int> #define vll vector<ll> #define pb push_back #define F first #define S second #define mp make_pair //salida rapida "\n" //DECIMALES fixed<<sp(n)<<x<<endl; //gcd(a,b)= ax + by //lCB x&-x //set.erase(it) - ersases the element present at the required index//auto it = s.find(element) //set.find(element) - iterator pointing to the given element if it is present else return pointer pointing to set.end() //set.lower_bound(element) - iterator pointing to element greater than or equal to the given element //set.upper_bound(element) - iterator pointing to element greater than the given element // | ^ //stoll string to long long using namespace std; //de int a string string is(int x){ string res=""; while(x>0){ res+=char('0'+(x%10)); x/=10; } reverse(res.begin(),res.end()); return res; } int main() { int n; cin>>n; vector<pair<string,pair<string,string> > >v; for(int i=1;i<10000;i++){ string ano=is(i); string aux(4-ano.size(),'0'); ano=aux+ano; string dia=ano.substr(2,2); string mes=ano.substr(0,2); reverse(dia.begin(),dia.end());reverse(mes.begin(),mes.end()); int D=stoll(dia),M=stoll(mes),A=stoll(ano); if(D>31 or D<1 or M<1 or M>12){ continue; } if(D==31){ if(M!=1 && M!=3 && M!=5 && M!=7 && M!=8 && M!=10 && M!=10 && M!=12){ continue; } } if(D==30){ if(M!=4 && M!=6 && M!= 9 && M!=11){ continue; } } if(M==2){ if(D==29 && A%4!=0){ continue; } } v.pb({dia,{mes,ano}}); } string s; for(int i=0;i<n;i++){ cin>>s; string dia=s.substr(0,2),mes=s.substr(3,2),ano=s.substr(6,4); for(int l=0;l<v.size();l++){ bool ok=false; if(stoll(ano)>stoll(v[l].S.S)){ continue; } if(stoll(ano)<stoll(v[l].S.S)){ ok=true; } if(stoll(mes)>stoll(v[l].S.F) && ok==false){ continue; } if(stoll(mes)<stoll(v[l].S.F)){ ok=true; } if(stoll(dia)>=stoll(v[l].F) && ok==false){ continue; } cout<<v[l].F<<'.'<<v[l].S.F<<'.'<<v[l].S.S<<'.'<<endl; break; } } return 0; }

Compilation message (stderr)

datum.cpp: In function 'int main()':
datum.cpp:71:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<std::__cxx11::basic_string<char>, std::pair<std::__cxx11::basic_string<char>, std::__cxx11::basic_string<char> > > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   71 |         for(int l=0;l<v.size();l++){
      |                     ~^~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...