Submission #783116

#TimeUsernameProblemLanguageResultExecution timeMemory
783116MatblubeType Printer (IOI08_printer)C++14
0 / 100
30 ms2412 KiB
#include <iostream> #include <iomanip> #include <string> #include <math.h> #include <algorithm> #include <cstring> #include <numeric> #include <vector> #include <map> #include <set> #include <deque> #include <unordered_map> #include <unordered_set> #include <queue> #include <stack> using namespace std; typedef long long ll; #define dbg(x) cerr<<#x<<": "<<x<<"\n"; #define fr(i, x) for(ll i=0 ; i<x ; i++) #define fra(x, v) for(auto x:v) #define fra1(x,v) for(auto &x:v) #define all(x) x.begin(), x.end() #define allr(x) x.rbegin(), x.rend() #define pb(x) push_back(x) #define F first #define S second #define inf 10000000000 #define sz(x) (ll) x.size() const double PI=acos(-1); const ll MOD=1e9+7, maxN=100010; struct uwu{ ll x ,y, z; }; ll gcd(ll a, ll b){return (!b)?a:(gcd(b, a%b));} ll lcm(ll a, ll b){ if(a>b) swap(a, b); return a/gcd(a, b)*b; } ll binpow(ll a, ll b){ ll cc=1; while(b){ if(b&1) cc*=a; a*=a; b>>=1; } return cc; } ll binpow1(ll a, ll b){ ll cc=1; while(b){ if(b&1) cc=cc*a%MOD; a=a*a%MOD; b>>=1; } return cc%MOD; } ll arr[50][50], n, m; ll dp[50][50]; void move(ll a, ll b){ for(ll i=a ; i<=n ; i++){ for(ll j=b ; j<=m ; j++){ dp[i][j]+=(max(dp[i-1][j], dp[i][j-1])); } } } ll subs(string a, string b){ if(a.size()>b.size()) swap(a, b); ll i=0; while(i<a.size() && i<b.size() && a[i]==b[i]) i++; return i; } bool comp(string a, string b){ return a.size()<b.size(); } void solve(){ ll n, aux; cin>>n; vector<string>v(n); fra1(x, v) cin>>x; sort(all(v), comp); // fra(x, v) cout<<x<<"\n"; string a, b; a=b=""; fra(x, v){ aux=subs(a, x); while(a.size()>aux){ a.pop_back(); b.push_back('-'); } a+=x.substr(aux); b+=x.substr(aux); b.push_back('P'); } cout<<b.size()<<"\n"; fra(x, b) cout<<x<<"\n"; cout<<"\n"; } int main(){ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); solve(); return 0; }

Compilation message (stderr)

printer.cpp: In function 'll subs(std::string, std::string)':
printer.cpp:77:12: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   77 |     while(i<a.size() && i<b.size() && a[i]==b[i]) i++;
      |           ~^~~~~~~~~
printer.cpp:77:26: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   77 |     while(i<a.size() && i<b.size() && a[i]==b[i]) i++;
      |                         ~^~~~~~~~~
printer.cpp: In function 'void solve()':
printer.cpp:95:23: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'll' {aka 'long long int'} [-Wsign-compare]
   95 |         while(a.size()>aux){
      |               ~~~~~~~~^~~~
#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...