245B - Internet Address - CodeForces Solution


implementation strings *1100

Please click on ads to support us..

Python Code:

import re
a=input()
b=re.findall(r"(http|ftp)(.+?)(ru)(.+)?", a)[0]
c=f"{b[0]}://{b[1]}.{b[2]}/{b[-1]}" if b[-1] else f"{b[0]}://{b[1]}.{b[2]}"
print(c)

C++ Code:

#include<bits/stdc++.h>
#define ll long long
#define w "YES\n"
#define n "NO\n"
#define en endl
#define agaarki if
#define tovaqteki for
#define qq long long q; cin>>q; for(int i=0;i<q;i++)
#define fx fixed<<setprecision(9)
#define iqBoost ios_base::sync_with_stdio(false), cin.tie(0);
using namespace std;
main()
{
    //B. ��������-�����
    string s;
    cin>>s;
    if(s[0]=='h'){
        cout<<"http://";
        s.erase(s.begin()+0);
        s.erase(s.begin()+0);
        s.erase(s.begin()+0);
        s.erase(s.begin()+0);}
    else
    {
        cout<<"ftp://";
        s.erase(s.begin()+0);
        s.erase(s.begin()+0);
        s.erase(s.begin()+0);
    }
    int p=-1;
    for(int i=0;i<s.size()-1;i++)
    {
        if(s[i]=='r' and s[i+1]=='u')
            p=i;
    }
    for(int i=0;i<p;i++)
        cout<<s[i];
    cout<<".ru";
    if(p!=s.size()-2)
    {
        cout<<'/';
        for(int i=p+2;i<s.size();i++)
            cout<<s[i];
    }

}

/**
asdasd
012345
10
6 9 4 7 8 2 3 5 0 1
 ~ ~ ~ ~ ~ ~ ~ ~ ~ ~

I will succes !

freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);


         **--------------------**
           RESHETOI AKAI MUSLIM
    vector < bool >prime(N, true);
    for(ll i = 2; i <= 1000000; i ++) {
        if(!prime[i]) {
            continue;
        }
        for(ll j = i * i; j <= 1000000; j += i) {
            prime[j] = false;
        }
    }
B.Shahrom
k.ibrohim
Z.muhammad
k.ismoil
---ME---
**/


Comments

Submit
0 Comments
More Questions

167. Two Sum II - Input array is sorted
387. First Unique Character in a String
383. Ransom Note
242. Valid Anagram
141. Linked List Cycle
21. Merge Two Sorted Lists
203. Remove Linked List Elements
733. Flood Fill
206. Reverse Linked List
83. Remove Duplicates from Sorted List
116. Populating Next Right Pointers in Each Node
145. Binary Tree Postorder Traversal
94. Binary Tree Inorder Traversal
101. Symmetric Tree
77. Combinations
46. Permutations
226. Invert Binary Tree
112. Path Sum
1556A - A Variety of Operations
136. Single Number
169. Majority Element
119. Pascal's Triangle II
409. Longest Palindrome
1574A - Regular Bracket Sequences
1574B - Combinatorics Homework
1567A - Domino Disaster
1593A - Elections
1607A - Linear Keyboard
EQUALCOIN Equal Coins
XOREQN Xor Equation