Submission #582408

#TimeUsernameProblemLanguageResultExecution timeMemory
582408mohammad_kilaniType Printer (IOI08_printer)C++17
100 / 100
39 ms5120 KiB
#include <bits/stdc++.h> using namespace std; #define oo 1000000010 #define mod 998244353 const int N = 25000; const int M = N * 20 + 1; string mx; bool compare(string &a,string &b){ for(int i = 0 ;i < (int)a.size() && i < (int)b.size();i++){ if(a[i] == b[i]) continue; if(a[i] == mx[i]) return false; if(b[i] == mx[i]) return true; return (a[i] < b[i]); } return (int)a.size() < (int)b.size(); } int main(){ int n; scanf("%d",&n); char tmpRead[21]; string s; vector< string > v; for(int i = 0 ;i < n;i++){ scanf("%s",tmpRead); s = (string)tmpRead; v.push_back(s); if((int)s.size() > (int)mx.size()) mx = s; } sort(v.begin(),v.end(), compare); string ans; for(int l, i = 0 ;i < (int)v.size();i++){ l = 0; if(i != 0){ while(l < (int)v[i].size() && l < (int)v[i - 1].size() && v[i][l] == v[i - 1][l]) l++; for(int j = (int)v[i - 1].size();j > l;j--){ ans += '-'; } } for(int j = l;j < (int)v[i].size();j++){ ans += v[i][j]; } ans += 'P'; } printf("%d\n",(int)ans.size()); for(int i = 0 ;i < (int)ans.size();i++){ putchar(ans[i]); puts(""); } return 0; }

Compilation message (stderr)

printer.cpp: In function 'int main()':
printer.cpp:26:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   26 |  scanf("%d",&n);
      |  ~~~~~^~~~~~~~~
printer.cpp:31:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   31 |   scanf("%s",tmpRead);
      |   ~~~~~^~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...