I attempted to solve D in python during the contest and kept on getting wrong answer... Turns out it was just an indentiation issue causing a block of code to not be run all the time. I submitted after the contest is done and got AC :')
Problem C can also be done in linear time (well, technically just the output is O(N^2), but the actual solution can be linear). Clojure code for this: ; Get the parsed input. (defn get-3prob-input [] (let [s (vec (read-line)) t (vec (read-line))] [s t])) ; Generate the increments and decrements. (defn idmap-prob3 [s t] (loop [s s t t idmap {:incs [], :decs []} index 0] (if (empty? s) (update idmap :decs (comp vec reverse)) (let [[u & rs] s [d & rt] t u (int u) d (int d)] (recur rs rt (cond (= u d) idmap (> u d) (update idmap :incs conj index) (< u d) (update idmap :decs conj index)) (inc index)))))) ; Substitute over the increments and (reversed) decrements. (let [[s t] (get-3prob-input) idmap (idmap-prob3 s t) x (second (reduce (fn [[current x] nextsub] (let [nxt (update current nextsub (constantly (t nextsub)))] [nxt (conj x (apply str nxt))])) [s []] (concat (:incs idmap) (:decs idmap))))] (println (count x)) (doseq [xi x] (println xi)))
Please give optimised approach of C What I did: Ran a loop and for every iteration I checked if the character of a is greater than corresponding character of b , if yes then i will replace it with character of b hence making it equal . After running this loop we have to make to change the characters remaining (those ones where char at a was less than char at b) For I sorted the remaing characters from b . then according to that order i replaced every character . It worked pretty well for given test cases but not accepted idk why pls help this is my code (in java). import java.util.*; public class Main{ public static void main(String [] args) { Scanner sc= new Scanner(System.in); String a=sc.next(); String b=sc.next(); char [] ac= a.toCharArray(); char [] bc= b.toCharArray(); ArrayList list = new ArrayList(); TreeMap map= new TreeMap(); int n=ac.length; int count=0; for(int i=0;i bc[i]) { ac[i] = bc[i]; list.add(new String(ac)); count++; } else if (ac[i] < bc[i]) { map.put(bc[i],i); } } for (Map.Entry entry : map.entrySet()) { ac[entry.getValue()]= entry.getKey(); list.add(new String(ac)); count++; } System.out.println(count); for(String s:list) { System.out.println(s); } } }
コンテスト終わったらすぐ投稿してくれるのありがたい
この速さは流石 ある意味解いた直後に見るための動画たちだったわけか
D問題をpythonでそのままシミュレーションしたらもちろんTLEでした。3完。
THAANNKKSSSS EVIMA LAB
B問題を理解するのにめっちゃ時間かかってしまった...
pretty nice solution for problem E
also thanks for providing O(n^2) solution to it...I was able to understand solution due to it only
@@divyanshpandey4697 same. n² solution is basically take only what you can while n solution is to take all minus those you can't
c問題全探索なのはわかったけどどう探索していけばいいかわからなった
それなぁ 😭
c問題
①sのi文字目がtのi文字目より辞書順で後ならリスト1にiを追加
②tのi文字目がsのi文字目より辞書順で後ならリスト2にiを追加
③リスト2を逆順にしたものをリスト1の後ろに追加
④③で作ったリストの順に文字を変えてAnswerリストに追加
⑤Answerリストの要素の個数と中身を出力
でAC出たけど、全探索でよかったのね。
自分もこれでやりました 貪欲おもしろいですよね
全く同じです。初学者で逆に全探索のやり方が分からなかった。
リスト1はmazukotti リスト2はmazumushi っていうめちゃ長いリスト名だったけど。
Dみて二次元配列で解けそうと思ってやったら、25,26でTLE出て絶望したわ
Same, Got TLE on last two. ;-;
2:24 制限時間は4秒なのに'2s'のままになってますね....
D問題、制限時間は説明内では4sと言っているのに表示が2sになっていますよ。
面白かった~ 5完でした
Fはダブリングだと楽だったんですね~ 次の行き先を二分探索で探していたら大変なことに
Dそれで良かったんだ〜!(列/行ごとにUnionFind持たせてleaderに端の座標を持たせて破壊時にマージ)
それでもRubyで1.3sにできたので満足
F問題を見てevimaさんのピザの動画を思い出した
Bの問題の意味を理解するのに凄い時間かかった...
AとBのみ正解で、Cは例文では成功するのに提出で不正解でした
単純にSとTを比較して、Sの方の文字順が後なら優先して変更。Sの方の文字順が先なら後回しで変更。
これを先頭の方から修正加える様にしてたのですが、んー、なんで上手くいかないんだろ?
解説みても分からなかったので、もっと検証して理解進めます!
解説ありがとうございました
Cは動画中の入力
===
abc
cat
===
で失敗する可能性がそれなりにあると思いますので、よければお試しください。
(答えは以下です。)
3
aac
aat
cat
@@evimalab 回答ありがとうございます!
提案されてる例で理解しました!
後回しの方は、文字の後ろの方から修正かけないといけなかったのですね...
問題を理解するのが、まだまだ慣れてないのでもっと過去問で勉強します
I attempted to solve D in python during the contest and kept on getting wrong answer... Turns out it was just an indentiation issue causing a block of code to not be run all the time. I submitted after the contest is done and got AC :')
F二分探索はともかくダブリングは思いつかなかった
4完、最近本当にだめだ、、、
Noのパターンを無視してA問題めっちゃ迷った。
最初XORで書いたけどダメだった…
B問題
何とかクリアしたけど少し考え方がめんどかったかも
Problem C can also be done in linear time (well, technically just the output is O(N^2), but the actual solution can be linear).
Clojure code for this:
; Get the parsed input.
(defn get-3prob-input []
(let [s (vec (read-line))
t (vec (read-line))]
[s t]))
; Generate the increments and decrements.
(defn idmap-prob3 [s t]
(loop [s s
t t
idmap {:incs [], :decs []}
index 0]
(if (empty? s)
(update idmap :decs (comp vec reverse))
(let [[u & rs] s
[d & rt] t
u (int u)
d (int d)]
(recur
rs
rt
(cond
(= u d) idmap
(> u d) (update idmap :incs conj index)
(< u d) (update idmap :decs conj index))
(inc index))))))
; Substitute over the increments and (reversed) decrements.
(let [[s t] (get-3prob-input)
idmap (idmap-prob3 s t)
x (second
(reduce
(fn [[current x] nextsub]
(let [nxt (update current nextsub (constantly (t nextsub)))]
[nxt (conj x (apply str nxt))]))
[s []]
(concat (:incs idmap) (:decs idmap))))]
(println (count x))
(doseq [xi x] (println xi)))
And where is G?
Please give optimised approach of C
What I did:
Ran a loop and for every iteration I checked if the character of a is greater than corresponding character of b , if yes then i will replace it with character of b hence making it equal .
After running this loop we have to make to change the characters remaining (those ones where char at a was less than char at b)
For I sorted the remaing characters from b . then according to that order i replaced every character .
It worked pretty well for given test cases but not accepted idk why pls help this is my code (in java).
import java.util.*;
public class Main{
public static void main(String [] args)
{
Scanner sc= new Scanner(System.in);
String a=sc.next();
String b=sc.next();
char [] ac= a.toCharArray();
char [] bc= b.toCharArray();
ArrayList list = new ArrayList();
TreeMap map= new TreeMap();
int n=ac.length;
int count=0;
for(int i=0;i bc[i]) {
ac[i] = bc[i];
list.add(new String(ac));
count++;
}
else if (ac[i] < bc[i]) {
map.put(bc[i],i);
}
}
for (Map.Entry entry : map.entrySet()) {
ac[entry.getValue()]= entry.getKey();
list.add(new String(ac));
count++;
}
System.out.println(count);
for(String s:list)
{
System.out.println(s);
}
}
}
Even i did same also it was my first contest at Atcoder problems were good.
Your code produced a wrong answer for the case used in the video.
[Input]
abc
cat
[Output from your code]
3
aac
cac
cat
void solve()
{
string s,t;
cin>>s>>t;
vector v;
string st=s;
if(s==t)
{
cout
@@pranavbhalerao308 same lol
@@evimalab oh yes mb
1