Блог пользователя object_oriented_program

Автор object_oriented_program, 9 лет назад, По-английски

I tried this sum and implemented a O(n2) solution, which should pass given n < 2000 , but it doesnt.. any explanations why ?

solution

Полный текст и комментарии »

  • Проголосовать: нравится
  • 0
  • Проголосовать: не нравится

Автор object_oriented_program, история, 9 лет назад, По-английски

Hello all, please see testcase 11 of this submission.. its behaving really weird

submission

Полный текст и комментарии »

  • Проголосовать: нравится
  • 0
  • Проголосовать: не нравится

Автор object_oriented_program, 9 лет назад, По-английски

Hello I am solving this problem . I am confused on how to fill up the graph so that I can implement shortest path using bfs.

Полный текст и комментарии »

  • Проголосовать: нравится
  • 0
  • Проголосовать: не нравится

Автор object_oriented_program, 10 лет назад, По-английски

Hello all, recently I gave my C++ exam, I came across this question. I was unable to understand the logic.

Can anyone explain what happens inside foo() ?

Thanks for your help :)

#include <iostream>
using namespace std;

void foo(char **p);

int main()
{
    char *argv[] = {"ab","cd","ef","gh","ij","kl"};
    foo(argv);
    return 0;
}

void foo(char **p)
{
    char *t = (p += sizeof(int))[-1];
    cout << t << '\n';
}

Полный текст и комментарии »

Теги c++
  • Проголосовать: нравится
  • +3
  • Проголосовать: не нравится

Автор object_oriented_program, 10 лет назад, По-английски

In the recent codechef contest, I solved the sum DIVGOLD using lists in Python.

Here is the code

for i in xrange(0,n):
		foo=list(s)
		k=foo.pop(i)
		for j in xrange(0,n):
			foo.insert(j,k)
			minm=''.join(foo)
			ans=min(minm,ans)
			foo.pop(j)

I am unable to implement it using list in STL. Erasing the element and inserting elements doesnt seem to work. Any solutions ?

Edit: Seems that there was a fault in my looping logic. Implementation using strings seems to be a much better option.


string s,ans,res; cin >> n; cin >> s; ans = s; for(i = 0; i < n; i++) { ch = s[i]; s.erase(s.begin()+i,s.begin()+i+1); for(j = 0; j < n; j++) { s.insert(j,1,ch); ans = min(ans,s); s.erase(s.begin()+j,s.begin()+j+1); } s.insert(i,1,ch); } cout << ans << endl;

Полный текст и комментарии »

  • Проголосовать: нравится
  • +1
  • Проголосовать: не нравится

Автор object_oriented_program, 10 лет назад, По-английски

The trend of people spamming useless comments like "give minus" has been around for quite a while. In recent times however it has seen an inflation to such a extent that it has become a real nuisance. What's worse is that now there have been increasing cases of spamming in blogs as well. If left unchecked , I fear that they might grow into a serious issues someday in the future.

My solution to the problem is to follow the following steps:

  1. People with a history of spamming comments should be banned from posting blogs or commenting. Alternatively people with a certain contribution (say -30 or less) shouldn't be allowed to comment or post blogs.

  2. Unrated people shouldn't be allowed to comment or post a blog. A person has to attended a minimum of 4-5 contests to be eligible for commenting or posting a blog. This will ensure that people don't open fake accounts just for spamming. Also I think most people with less than 4 contests don't generally comment or post blogs.

Suggestions are welcome.

Полный текст и комментарии »

  • Проголосовать: нравится
  • +19
  • Проголосовать: не нравится