Submission #18446

# Submission time Handle Problem Language Result Execution time Memory
18446 2016-02-02T12:02:03 Z chan492811 Collider (IZhO11_collider) C++
0 / 100
305 ms 33992 KB
#include <cstdio>
#include <malloc.h>
using namespace std;
int n,m,sqrtn;
struct node{
    char data;
    node *next,*prev;
};
node *front[100000],*finding;
char arr[1000010];
void find(int a){
    int i=0;
    while(i*sqrtn+sqrtn<a) i++; finding=front[i]; i=i*sqrtn;
    while(i<a) finding=finding->next,i++;
}
int main(){
    int i,j,a,s;
    char flag,data;
    node *temp,*prev,*newnode,*free1,*free2;
    scanf("%d %d %s\n",&n,&m,arr);
    for(i=1;i*i<n;i++); sqrtn=i; j=0; prev=(node *)malloc(sizeof(node));
    for(i=0;i<n;i++){
        temp=(node *)malloc(sizeof(node)); temp->data=arr[i]; temp->prev=prev; prev->next=temp;
        if(j*sqrtn==i){
            front[j++]=temp;
        }
        prev=temp;
    }
    for(i=0;i<m;i++){
        scanf("%c ",&flag);
        if(flag=='a'){
            scanf("%d %d\n",&a,&s); j=0; a--; s--;
            find(a);
            data=finding->data; free1=finding;
            find(s); temp=finding;
            newnode=(node *)malloc(sizeof(node)); newnode->data=data; newnode->prev=temp; newnode->next=temp->next;
            temp->next=newnode; newnode->next->prev=newnode;
            find(a); temp=finding;
            temp->next->prev=temp->prev; temp->prev->next=temp->next;
            for(j=0;j*sqrtn<n;j++){
                if(j*sqrtn>s) front[j]=front[j]->prev;
                else if(j*sqrtn>=a) front[j]=front[j]->next;
            }
            free(free1);
        }else{
            scanf("%d\n",&a);
            find(a);
            printf("%c\n",finding->data);
        }
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 2840 KB Output isn't correct
2 Runtime error 0 ms 2840 KB SIGSEGV Segmentation fault
3 Incorrect 12 ms 5876 KB Output isn't correct
4 Incorrect 101 ms 27788 KB Output isn't correct
5 Incorrect 186 ms 27788 KB Output isn't correct
6 Incorrect 248 ms 30956 KB Output isn't correct
7 Incorrect 263 ms 33992 KB Output isn't correct
8 Incorrect 118 ms 33992 KB Output isn't correct
9 Incorrect 305 ms 33992 KB Output isn't correct
10 Incorrect 211 ms 33992 KB Output isn't correct