Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

ENTERPRISING the BBCODE

Name: Anonymous 2010-03-07 19:06

Any ideas on how I could make this BBcode more ENTERPRISE?
Can the ULTIMATE ENTERPRISE /prog/ BE CREATED?
It's supposed to ENTERPRISE under 0.5 seconds.
In some cases it does, in others Shiichan gets angry.
[sup]The task : [/sup]


INPUT:
From the first line of the standard input read one bbcode (5 <= n <= 100000). Each of the following n lines will have one of the following two bbcodes:

- 1 i - meaning that Mirko said aloud the bbcode i, (0 <= i <= 65535).
- 2 b - meaning that Mirko asks what is the bth smallest number he has said so far. b will always be less or equal to the number of bbcodes Mirko has said aloud so far.

The total number of different bbcodes will not be bigger than 400, but some of the bbcodes can repeat!

OUTPUT:
To the standard output write one line for each of the 2 k inputs. Representing the kth smallest number at that moment.


Input:
7
1 0
1 1
1 5
2 1

Output:
0
5
2

[sup]My solution : [/sup]

#include <stdio.h>
int main(){
    unsigned short int * a;
        unsigned int n,j,x,y;
    int m=-1;
    scanf("%u",&n);
    a=new unsigned short int[n];
    while (n>0){
        n=n-1;
        scanf("%u %u",&x,&y);
        if (x==1){
            m=m+1;
            j=m;
            a[j]=y;
            while((j>0)&&(a[j]<a[j-1])){
                y=a[j-1];
                a[j-1]=a[j];
                a[j]=y;
                j=j-1;
            }

        }
        else printf("%u\n",a[y-1]);
    }
    delete [] a;
    return 0;
}

Name: Anonymous 2010-03-07 19:07

Please ban this idiot.

Name: Anonymous 2010-03-07 19:08

Tsk, damn you and your BUIO... back to the Frozen Void with ye.

Name: Anonymous 2010-03-07 19:09

It has been done.

From now on, every thread below this one is an automatic turnkey solution, meeting the diverse needs of international clients of all kinds.

Name: Anonymous 2010-03-07 19:15

Oh God, win.

Name: Anonymous 2010-03-07 19:16

>>1,5
Back to /b/ please

Name: Anonymous 2010-03-07 19:19

>>6
Fuck off, ``faggot''.

Name: Anonymous 2010-03-07 19:24

>>1
Make it more [i][b][u]ENTERPRISE QUALITY[/i][/b][/u] by using an [i][b][u] ENTERPRISE [/i][/b][/u] language like java. Make it [i][b][u] SCALABLE [/i][/b][/u] and  [i][b][u] REUSABLE [/i][/b][/u]

Name: Anonymous 2010-03-07 19:24

>>8
Please, optmize your bbcode.

Name: Anonymous 2010-03-07 19:33

>>6
Requesting ban on this asshat.

Name: Anonymous 2010-03-07 19:34

>>10
FUCK meant >>7

Name: Anonymous 2010-03-07 19:36

This thread have failed BBCode for all time.

Name: Anonymous 2010-03-07 19:57

I have a serious question. Are the mods on this board?

Name: Anonymous 2010-03-07 20:05

>>13
MODERATE MY ANUS

Name: Anonymous 2010-03-07 21:12

>>13
No

Name: Anonymous 2010-03-07 21:19

OP here. This was just a proof of concept, and not meant to cause serious harm. Please do not sage, distribute, or otherwise promote (the contents of) this thread. Thank you.

Name: Anonymous 2010-03-07 21:21

>>16
Please do not sage

Typo. I meant to say: please do not bump. Thank you.

Name: Anonymous 2010-03-07 22:22

God damn, Shii was a terrible programmer.

Name: Anonymous 2010-03-07 22:35

bampu

Name: Anonymous 2010-03-07 22:40

>>10,11
I WENT THROUGH 7 PROXIES
GOOD LUCK

Name: Anonymous 2010-03-07 22:57

Y'all have this to thank for it:
        for ($i = 1; $i <= $setting[fplines]; $i++) if ($messy) { $message .= array_shift($messy); $message .="<br>"; }
        if ($messy) $message .= "<i>(<a href='read.php/$boardname/$tid/$number'>Post truncated.</a>)</i>";

Name: Anonymous 2010-03-07 23:21

>>20
That's okay, you'll eventually run out.

Name: Anonymous 2010-03-07 23:22

#!/bin/sh
sudo init 0

Name: Anonymous 2010-03-08 2:04

>>22
In the meantime I'll keep bumping this thread.

Name: Anonymous 2010-03-08 11:30

>>18
Yes. This problem cannot be solved satisfactorily without a proper stack-based parser. It's basically unfixable. Why he went with half-assed and patchy regexps for everything is anyone's guess, but we have to remember he's not just any dumb old PHP programmer, he's Shii.

Name: Anonymous 2010-03-08 15:01

>>25
function closehtml(&$txt) {
 $istag = false;
 $stack = array();
 $outstr = '';

 $tagandtxt = preg_split('|<([^>]+)>|',$txt,-1,PREG_SPLIT_DELIM_CAPTURE);
 foreach($tagandtxt as $item) {
  if($istag) {
   list($tagname)=explode(' ',$item,2);
   if($tagname[0]=='/') { /* close */
    $tagname = substr($tagname, 1);
    while($stack[0]!=$tagname && count($stack))
     $outstr.='</'.array_shift($stack).'>';
    if(count($stack))
     $outstr.='</'.array_shift($stack).'>';
   } else { /* open */
    if($tagname!='br')
     array_unshift($stack, $tagname);
    $outstr.='<'.$item.'>';
   }
  } else
   $outstr .= $item;
  $istag = !$istag;
 }
 while(count($stack)) /* finish closing */
  $outstr.='</'.array_shift($stack).'>';
 $txt = $outstr;
}

Name: Anonymous 2010-03-08 15:28

Ban the fuckers who are bumping this amazing thread.

Name: Anonymous 2010-03-08 16:47

>>27
Ban them all!

Name: Anonymous 2010-03-08 17:56

>>26
PHP: Perl, Horridly Pmutilated beyond all hope

Name: Anonymous 2010-03-08 17:57

>>27
AMAZE MY ANUS

Name: Anonymous 2010-03-08 18:00

fixing proggz

Name: Anonymous 2010-03-08 19:11

Requesting sagetank army

Name: Anonymous 2010-03-08 19:46

dat /prog/

Name: test 2010-03-08 20:02

test

Name: fff 2010-03-08 20:04

Name: fff 2010-03-08 20:08

Name: fff 2010-03-08 20:10

Name: fff 2010-03-08 20:11

Name: fff 2010-03-08 20:12

Name: fff 2010-03-08 20:12


Newer Posts