Submission #799726

# Submission time Handle Problem Language Result Execution time Memory
799726 2023-07-31T21:13:35 Z YassirSalama Type Printer (IOI08_printer) C++14
0 / 100
38 ms 17904 KB
#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

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 time Memory Grader output
1 Incorrect 1 ms 212 KB Expected EOF
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Expected EOF
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 320 KB Expected EOF
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 320 KB Expected EOF
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 340 KB Expected EOF
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 980 KB Expected EOF
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 2636 KB Expected EOF
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 16 ms 9084 KB Expected EOF
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 38 ms 17904 KB Expected EOF
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 37 ms 17860 KB Expected EOF
2 Halted 0 ms 0 KB -