Submission #783151

#TimeUsernameProblemLanguageResultExecution timeMemory
783151MatblubeType Printer (IOI08_printer)C++14
0 / 100
3 ms468 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(); } // ordenar lexicograficamente //tener los caracteres de las palabras mas largas al final de cada string void sortString(ll x, ll y, ll n, string a, vector<string>&v){ if(y-x<2) return; vector<string>s[26]; string aux=""; char uwu; for(ll i=x ; i<y ; i++){ if(sz(v[i])==n){ aux=v[i]; continue; } uwu=v[i][n]; s[uwu-'a'].pb(v[i]); } ll xd=x, pro; if(aux.size()) v[xd++]=aux; fr(i, 26){ if(i==a[n]-'a') continue; pro=xd; fra1(nosebro,s[i]) v[xd++]=nosebro; sortString(pro, xd, n+1, a, v); } pro=xd; fra1(nosebro, s[a[n]-'a']) v[xd++]=nosebro; sortString(pro, xd, n+1, a, v); } void solve(){ ll n, aux; cin>>n; vector<string>v(n); string xdxd; fra1(x, v){ cin>>x; if(x.size()>xdxd.size()) xdxd=x; } sortString(0, n, 0, xdxd, v); // 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"; } int main(){ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int t; cin>>t; while(t--) 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:126: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]
  126 |         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...