Submission #799726

#TimeUsernameProblemLanguageResultExecution timeMemory
799726YassirSalamaType Printer (IOI08_printer)C++14
0 / 100
38 ms17904 KiB
#include <iostream> #include <vector> #include <algorithm> #include <unordered_map> #include <set> #include <unordered_set> #include <iomanip> #include <cmath> #include <limits> #include <map> #include <utility> #include <cctype> #include <string> #include <cstring> #include <stack> #include <queue> #include <functional> #include <iterator> using namespace std; #define OVL(x,s) for(auto y:x) cout<<y<<s; cout<<"\n"; void dbg_out() { cout << endl; } template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T) { cout << ' ' << H; dbg_out(T...); } #define dbg(...) cout << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__); #define endl "\n" #define pb push_back #define F first #define S second #define ll long long #define mod 1000000007 #define all(v) v.begin(),v.end() #define int long long signed main(){ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); int n; cin>>n; vector<string> v(n); for(int i=0;i<n;i++) cin>>v[i]; int ans=0; sort(all(v),[&](string& a,string& b){ if (a.compare(0, b.size(), b) == 0 || b.compare(0, a.size(), a) == 0) return a>b; return a.size()<b.size(); }); // OVL(v,"\n") string now=""; vector<string> operations; for(int i=0;i<n;i++){ string s=v[i]; if(now==s){ operations.push_back("P"); continue; } while(s.compare(0,now.size(),now)!=0) { operations.push_back("-"); now.pop_back(); } int j=now.size(); while(j<s.length()){ operations.push_back(string(1,s[j])); now+=s[j]; j++; } operations.push_back("P"); } cout<<operations.size()<<endl; OVL(operations,'\n') }

Compilation message (stderr)

printer.cpp: In function 'int main()':
printer.cpp:59:9: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   59 |  while(j<s.length()){
      |        ~^~~~~~~~~~~
printer.cpp:38:5: warning: unused variable 'ans' [-Wunused-variable]
   38 | int ans=0;
      |     ^~~
#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...