Submission #1036003

#TimeUsernameProblemLanguageResultExecution timeMemory
1036003vux2codeType Printer (IOI08_printer)C++17
100 / 100
82 ms11212 KiB
// Src : Vux2Code // Note : none #include <bits/stdc++.h> #define pq_rvs pll,vector<pll>,greater<pll> using namespace std; typedef long long ll; typedef pair <ll, ll> pll; struct Edge {ll u, v, w;}; const ll maxN = 2e5 + 5, inf64 = 1e18, mod = 1e9 + 7, maxLog = 20; ll t = 1; ll n; string s [maxN], lg; vector <char> ans; ll pre (string x, string y) { ll siz = min (x. size (), y. size ()); for (int i = 0; i < siz; i ++) { if (x [i] != y [i]) return i; } return siz; } bool cmp (string x, string y) { ll tmp1 = pre (x, lg), tmp2 = pre (y, lg); if (tmp1 == tmp2) return x < y; return tmp1 < tmp2; } void solve () { cin >> n; for (int i = 1; i <= n; i ++) { cin >> s [i]; if (lg. size () < s [i]. size ()) lg = s [i]; } sort (s + 1, s + n + 1, cmp); for (char i : s [1]) ans. push_back (i); ans. push_back ('P'); for (int i = 2; i <= n; i ++) { ll tmp = pre (s [i - 1], s [i]); for (int j = s [i - 1]. size () - 1; j >= tmp; j --) ans. push_back ('-'); for (int j = tmp; j <= s [i]. size () - 1l; j ++) ans. push_back (s [i] [j]); ans. push_back ('P'); } cout << ans. size () << '\n'; for (char i : ans) cout << i << '\n'; } int main (){ ios::sync_with_stdio (0); cin. tie (0); cout. tie (0); // #define task "chill" // freopen (task".inp", "r", stdin); // freopen (task".out", "w", stdout); //cin >> t; while (t --) solve (); return 0; }

Compilation message (stderr)

printer.cpp: In function 'void solve()':
printer.cpp:46:29: warning: comparison of integer expressions of different signedness: 'int' and 'long unsigned int' [-Wsign-compare]
   46 |         for (int j = tmp; j <= s [i]. size () - 1l; j ++) ans. push_back (s [i] [j]);
      |                           ~~^~~~~~~~~~~~~~~~~~~~~~
#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...