Submission #340392

#TimeUsernameProblemLanguageResultExecution timeMemory
340392HazemDatum (COCI20_datum)C++14
40 / 50
1096 ms492 KiB
/* ID: tmhazem1 LANG: C++14 TASK: pprime */ #include <bits/stdc++.h> using namespace std; #define S second #define F first #define LL long long const int N = 4e2 + 10; LL LINF = 100000000000000000; LL INF = 1000000000; int MOD = 1e9+7; int days[] ={31,28,31,30,31,30,31,31,30,31,30,31}; string get_nxt(string s){ int d = (s[0]-'0')*10+(s[1]-'0'), m = (s[3]-'0')*10+(s[4]-'0'); int y = 0; for(int i=6;i<=9;i++) y = y*10+(s[i]-'0'); if(d==days[m-1]+(m==2&&y%4==0)){ d = 1; if(m==12)y++,m = 1; else m++; } else d++; string ret = ""; ret += ('0'+(d/10)); ret += ('0'+(d%10)); ret += ('0'+(m/10)); ret += ('0'+(m%10)); for(int i=3;i>=0;i--) ret += '0'+(y%10),y /= 10; reverse(ret.begin()+4,ret.end()); return ret; } bool check(string s){ string r = ""; for(char c:s) if(c>='0'&&c<='9')r += c; bool q = 1; for(int i=0;i<r.size();i++) q &= r[i]==r[r.size()-i-1]; return q; } int main() { //freopen("out.txt","w",stdout); int n; scanf("%d",&n); for(int i=1;i<=n;i++){ string s; cin>>s; while(1){ string r = get_nxt(s); s = ""; for(int i=0;i<2;i++) s += r[i]; s+= '.'; for(int i=2;i<4;i++) s += r[i]; s += '.'; for(int i=4;i<=7;i++) s += r[i]; s+='.'; if(check(r))break; } cout<<s<<endl; } }

Compilation message (stderr)

datum.cpp: In function 'bool check(std::string)':
datum.cpp:59:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   59 |     for(int i=0;i<r.size();i++)
      |                 ~^~~~~~~~~
datum.cpp: In function 'int main()':
datum.cpp:68:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   68 |     scanf("%d",&n);
      |     ~~~~~^~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...