Submission #18559763


Source Code Expand

Copy
#import <Foundation/Foundation.h>

int main(int argc, const char * argv[]) {
    @autoreleasepool {

        NSData *stdinData = [[NSFileHandle fileHandleWithStandardInput] availableData];
        NSString *stdinString = [[NSString alloc] initWithData:stdinData encoding:NSUTF8StringEncoding];
        NSMutableArray<NSMutableArray<NSString *> *> *stdinStrArr = [NSMutableArray new];
        for (NSString *str in [stdinString componentsSeparatedByString:@"\n"]) {
            [stdinStrArr addObject:[[str componentsSeparatedByString:@" "] mutableCopy]];
        }

        NSMutableArray<NSNumber *> *aList = [NSMutableArray new];
        for (NSString *i in [stdinStrArr objectAtIndex:1]) {
            NSNumber *currentIndex = [NSNumber numberWithLongLong:[i longLongValue]];
            long long replaceIndex = [currentIndex longLongValue] - 1;
            [aList addObject:[NSNumber numberWithLongLong:0]];
            NSNumber *newValue = [NSNumber numberWithLongLong:[[aList objectAtIndex:replaceIndex] longLongValue] + 1];
            [aList replaceObjectAtIndex:replaceIndex withObject:newValue];
        }
        [aList addObject:[NSNumber numberWithLongLong:0]];

        NSFileHandle *fileHandle = [NSFileHandle fileHandleWithStandardOutput];

        for (NSNumber *n in aList) {
            [fileHandle writeData:[[NSString stringWithFormat:@"%@", n] dataUsingEncoding:NSUTF8StringEncoding]];
            [fileHandle writeData:[@"\n" dataUsingEncoding:NSUTF8StringEncoding]];
        }
        [fileHandle closeFile];

    }
    return 0;
}

Submission Info

Submission Time
Task C - management
User log5
Language Objective-C (Clang 10.0.0)
Score 300
Code Size 1590 Byte
Status AC
Exec Time 992 ms
Memory 112768 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 3
AC × 15
Set Name Test Cases
Sample sample_01, sample_02, sample_03
All binary_01, binary_02, line_01, line_02, random_01, random_02, random_03, random_04, sample_01, sample_02, sample_03, small_01, star_01, star_02, star_03
Case Name Status Exec Time Memory
binary_01 AC 992 ms 109856 KB
binary_02 AC 919 ms 110424 KB
line_01 AC 928 ms 110320 KB
line_02 AC 924 ms 110300 KB
random_01 AC 929 ms 110076 KB
random_02 AC 769 ms 93208 KB
random_03 AC 814 ms 96056 KB
random_04 AC 347 ms 47844 KB
sample_01 AC 33 ms 16500 KB
sample_02 AC 34 ms 16660 KB
sample_03 AC 31 ms 16436 KB
small_01 AC 29 ms 16792 KB
star_01 AC 917 ms 108608 KB
star_02 AC 901 ms 108696 KB
star_03 AC 929 ms 112768 KB