Page 2 of 2

Re: 10158 - War

Posted: Fri May 16, 2014 9:05 pm
by brianfry713
Input:

Code: Select all

100
2 83 86
4 15 93
2 86 92
4 21 62
4 90 59
3 26 40
4 72 36
2 68 67
3 82 30
4 23 67
3 29 2
4 58 69
4 93 56
2 42 29
1 21 19
1 37 98
2 15 70
1 26 91
3 56 73
2 70 96
1 5 25
2 27 36
2 46 29
4 57 24
3 82 45
1 67 34
4 43 50
3 8 76
4 88 84
4 51 54
1 32 60
1 68 39
3 26 86
3 39 95
4 34 78
3 1 97
1 17 92
1 56 1
2 86 41
4 89 44
4 40 29
4 17 97
2 81 75
1 27 67
3 97 53
4 65 6
1 19 24
2 71 32
3 3 19
4 68 8
1 40 49
2 23 18
2 46 51
1 55 79
2 64 28
1 50 93
1 34 64
1 14 87
4 43 91
1 65 59
2 32 51
4 28 75
3 74 21
2 95 29
3 35 93
4 28 43
1 28 29
4 4 43
3 13 38
3 40 4
2 28 88
4 96 24
3 70 83
2 99 72
2 44 90
3 39 54
3 69 82
4 64 97
1 55 4
1 11 22
3 99 43
3 68 40
2 11 10
3 1 61
1 78 5
3 36 44
1 22 65
3 16 82
3 24 37
1 24 0
4 52 99
4 50 68
2 73 31
3 30 33
4 60 63
1 81 99
2 59 73
4 68 90
1 26 66
1 40 90
1 76 42
1 7 45
4 79 18
1 12 48
1 59 9
4 10 42
2 6 1
4 72 21
2 19 99
4 4 39
2 40 67
3 28 27
1 84 58
2 24 22
3 96 81
1 84 92
2 72 50
4 85 22
3 40 42
3 13 98
2 24 90
1 81 19
3 32 55
2 4 79
3 73 76
3 55 60
2 79 84
4 5 21
2 4 13
4 54 26
3 44 2
2 6 84
1 42 68
1 89 72
1 58 98
1 8 53
2 3 33
3 48 90
1 67 46
3 29 0
2 88 97
2 90 3
2 63 97
2 92 86
4 52 96
2 88 57
3 36 60
1 21 60
3 28 27
3 48 56
4 94 97
3 43 39
1 28 3
3 81 47
4 59 51
1 34 39
1 15 27
1 29 49
4 85 29
1 35 77
2 38 71
1 89 67
4 92 95
3 44 29
2 82 40
1 69 26
1 61 42
2 17 23
3 81 9
4 25 96
3 77 34
2 26 24
2 14 68
3 58 12
3 0 46
1 94 16
3 78 29
3 90 47
4 51 80
4 93 57
3 12 86
3 55 12
3 12 79
3 69 89
1 55 41
1 33 87
3 38 66
2 84 56
2 6 60
4 37 5
2 17 18
3 83 73
2 73 37
3 83 7
4 57 14
4 29 0
2 18 38
2 88 74
2 57 81
4 58 70
2 17 39
3 63 22
4 73 47
3 62 82
2 92 91
2 15 21
4 74 91
2 51 31
3 37 40
2 30 98
1 81 16
4 2 31
3 96 4
2 80 18
1 70 62
2 79 77
1 36 4
4 83 7
4 57 44
3 11 27
3 36 60
2 5 63
2 44 11
4 34 91
2 55 14
3 68 93
3 5 82
3 82 17
3 93 74
2 93 86
3 43 74
2 13 79
1 62 75
1 19 10
3 94 17
4 35 37
2 53 43
4 28 25
2 10 18
4 36 63
3 90 58
2 4 71
2 33 85
4 73 4
1 5 50
3 3 85
2 95 39
3 20 67
1 63 77
1 81 65
3 36 55
3 18 11
4 32 96
1 21 70
3 72 27
1 40 83
4 98 30
3 47 50
4 73 14
1 22 47
1 82 35
4 4 54
1 98 86
3 78 59
2 62 83
1 48 23
3 72 22
2 35 21
4 65 47
3 76 69
2 1 3
4 33 7
2 28 6
1 20 84
4 34 98
4 76 98
2 52 71
3 59 6
2 16 24
3 39 0
2 9 53
2 14 38
4 26 67
4 23 87
2 32 22
4 75 50
3 90 54
2 31 13
2 94 81
2 3 20
4 82 81
2 15 96
1 4 22
1 51 97
3 34 81
1 15 57
3 95 99
1 97 83
2 54 77
3 87 32
4 21 66
4 60 82
2 85 86
4 30 90
1 14 76
2 20 92
2 28 39
1 90 36
2 18 43
2 28 82
1 10 55
3 25 15
1 37 53
3 22 83
4 57 97
4 26 69
3 51 49
3 28 39
2 88 10
1 77 90
4 99 52
4 87 77
1 57 66
4 17 41
1 68 98
2 95 76
3 66 28
2 28 8
4 78 97
2 72 74
2 0 25
4 83 12
2 82 21
3 34 39
2 21 59
2 57 54
2 62 72
3 16 52
4 62 82
2 17 54
4 15 6
4 64 90
2 91 72
1 37 59
4 71 80
2 56 90
2 70 52
2 11 69
4 61 83
3 12 0
1 38 67
3 89 32
4 4 75
3 41 12
3 69 36
1 56 44
2 49 14
3 14 26
2 83 39
2 35 52
2 93 90
2 9 31
1 64 35
2 95 77
2 33 98
1 93 68
4 60 33
3 86 71
2 77 40
3 81 61
1 23 50
1 54 75
4 42 24
1 19 89
4 69 38
4 76 83
1 33 43
4 56 81
4 66 11
2 12 92
4 2 68
4 2 74
4 18 16
1 77 87
3 73 57
2 25 33
2 96 18
3 53 26
2 80 93
3 48 5
3 29 59
1 60 62
2 19 80
1 2 10
2 26 83
4 40 8
2 38 57
1 31 10
2 5 90
3 91 38
2 21 67
4 71 80
1 95 99
3 88 54
2 69 32
3 10 73
4 33 63
2 79 94
4 99 51
3 64 42
2 86 15
2 15 86
2 11 34
4 87 22
4 73 43
1 42 54
4 24 39
2 63 18
2 12 69
4 4 33
4 34 19
2 35 87
4 69 50
3 2 37
2 89 10
4 60 4
4 57 29
2 16 92
4 22 5
1 79 61
1 78 47
4 45 82
2 99 51
3 86 53
1 48 94
1 6 7
2 17 64
3 20 80
4 94 54
1 37 33
4 17 12
2 17 9
2 56 8
3 45 95
2 71 95
1 59 1
1 52 71
1 25 43
4 91 89
1 66 78
1 50 96
3 33 13
3 99 70
2 68 15
2 42 39
3 63 98
2 39 2
2 31 28
3 4 71
2 83 38
2 95 40
3 72 26
1 58 25
1 52 45
4 46 39
2 83 3
1 25 42
1 39 74
4 96 30
2 94 13
3 19 60
1 92 32
2 79 90
3 35 95
2 7 41
1 70 76
4 84 1
2 0 92
4 96 40
1 63 35
1 73 6
2 23 51
4 51 30
3 4 65
4 2 25
4 91 47
2 84 31
2 19 31
3 28 27
2 19 43
4 23 68
3 39 43
1 88 94
3 80 98
4 18 52
3 98 95
3 5 79
2 66 98
2 72 78
1 66 97
1 47 72
4 86 12
2 77 0
4 97 32
4 35 51
3 98 49
3 61 6
1 3 25
4 28 97
1 33 15
2 81 14
2 97 0
2 8 29
3 13 79
2 16 14
3 75 65
1 30 26
2 16 29
3 52 9
2 15 95
4 28 76
1 13 26
2 62 86
1 63 0
4 97 16
1 82 44
3 20 26
4 65 94
1 34 46
4 53 62
1 86 42
3 34 7
1 34 69
1 15 84
2 24 82
2 51 16
4 43 37
2 61 2
4 60 88
2 20 41
4 24 28
3 8 62
4 70 96
1 66 11
3 15 87
3 32 90
4 93 33
2 80 94
3 13 54
4 44 75
4 38 51
2 73 11
2 68 81
2 83 99
1 35 14
4 69 46
1 72 91
4 11 23
2 57 36
1 39 81
4 14 71
3 18 96
4 83 64
4 97 0
2 74 35
1 90 57
4 49 29
4 90 92
4 29 49
1 22 40
4 43 55
1 66 25
1 53 60
1 20 57
1 87 83
2 21 26
3 5 27
3 28 69
1 27 98
1 63 21
4 83 16
1 23 82
2 11 35
3 63 8
3 68 95
1 60 68
4 9 73
2 87 54
4 57 81
1 29 96
1 42 80
4 9 55
3 54 66
3 59 81
3 73 1
3 71 13
1 99 22
3 55 61
4 80 71
1 3 0
1 0 42
4 12 4
2 59 58
3 94 17
1 36 90
2 26 14
1 37 65
2 21 20
1 63 0
2 86 4
4 58 56
4 10 68
2 69 28
3 46 74
2 5 10
4 65 89
1 90 26
2 38 99
2 0 62
2 32 48
2 17 7
3 97 69
3 28 39
1 70 85
3 80 42
4 33 7
2 0 50
1 85 88
3 90 40
4 47 25
3 61 94
4 30 91
3 54 38
3 92 30
1 34 85
1 94 80
2 44 2
4 84 22
4 25 57
1 2 92
3 96 86
4 40 49
2 12 56
1 54 48
2 28 82
2 88 76
4 97 20
3 94 5
1 23 69
1 15 17
1 53 99
1 54 50
3 10 92
4 58 64
4 41 21
1 69 10
4 90 2
2 47 16
3 81 39
4 17 6
3 1 11
2 78 65
2 66 76
2 61 34
3 36 27
1 99 97
3 60 39
3 67 86
2 8 67
4 66 36
3 93 37
1 19 67
1 96 34
3 17 95
3 50 31
4 8 30
3 25 42
1 47 61
4 34 69
4 63 35
1 51 80
1 97 0
3 61 96
2 1 14
1 28 16
3 82 25
2 33 2
3 23 49
1 51 35
4 46 99
1 29 2
1 49 99
1 89 13
3 63 66
4 84 94
1 36 76
3 71 9
4 0 84
4 90 35
3 50 81
1 50 62
4 78 64
1 58 53
4 34 69
2 77 5
3 36 42
4 72 65
1 10 65
4 49 7
2 76 58
4 2 60
4 82 38
2 14 96
3 58 30
4 69 7
2 27 95
3 13 67
4 60 29
4 92 31
2 12 7
2 13 62
4 28 96
4 56 10
2 41 69
2 95 90
1 54 69
1 8 82
2 26 95
1 14 87
1 57 51
3 10 64
3 23 93
2 26 1
3 25 94
1 6 89
3 47 95
1 84 3
4 40 82
4 73 48
3 90 5
4 66 67
1 4 90
2 90 68
4 35 93
1 1 51
4 10 51
4 88 35
2 48 75
2 56 0
3 51 42
2 49 60
4 43 72
3 11 33
1 56 40
3 59 36
3 10 28
3 97 75
3 24 56
2 25 85
4 19 71
4 80 24
1 96 67
2 3 30
3 46 86
3 94 45
3 52 8
2 98 5
2 44 30
3 47 7
2 0 78
2 7 58
1 79 7
3 75 10
1 4 8
3 26 2
3 85 6
4 23 4
2 37 1
1 10 48
4 69 0
2 50 8
1 56 87
4 28 62
4 83 18
3 23 45
1 61 82
2 7 57
3 11 94
3 44 57
3 37 26
3 60 28
2 41 84
4 82 65
3 33 48
4 44 23
2 10 85
3 83 44
2 12 55
3 42 0
1 20 89
1 50 49
2 37 42
3 14 24
3 54 9
2 64 54
3 19 16
4 60 99
3 6 63
3 99 5
4 1 77
1 29 28
4 86 17
4 79 83
2 89 37
4 47 53
4 80 24
4 99 84
3 14 43
1 84 42
2 7 96
2 18 25
3 31 63
3 86 94
4 17 35
2 58 82
2 53 15
3 17 14
1 41 6
4 35 38
3 31 52
2 9 45
4 24 56
1 71 2
4 6 85
1 89 74
2 56 88
2 70 38
1 2 79
3 18 66
3 42 50
1 84 59
1 61 35
3 24 6
4 56 13
3 47 54
3 44 10
1 57 32
4 51 86
2 99 4
4 89 46
3 84 82
3 72 43
1 68 19
2 18 76
4 53 75
2 15 19
2 69 77
4 9 80
1 32 31
3 22 20
2 13 56
1 64 28
1 50 48
1 94 18
4 4 72
4 67 39
1 93 9
1 54 70
4 50 55
4 50 29
1 48 42
1 77 6
2 54 8
4 98 3
4 70 7
4 69 26
1 40 71
3 88 26
2 16 76
3 27 78
2 59 26
4 99 4
1 67 58
4 88 8
3 76 30
1 39 51
1 42 92
3 6 80
3 93 49
1 86 28
3 9 87
3 26 38
1 49 58
1 81 46
3 20 74
1 62 39
4 54 35
1 34 57
3 35 7
4 64 83
2 3 37
4 42 48
1 0 68
2 46 49
4 21 59
3 87 21
2 43 75
3 10 62
2 70 97
1 17 61
3 24 17
3 58 59
3 93 59
4 9 57
4 46 30
1 2 17
1 96 13
3 74 23
4 60 94
2 6 63
3 34 39
2 52 49
1 18 42
2 5 4
1 92 2
2 87 4
3 56 1
3 48 27
1 54 39
4 9 45
3 26 80
1 12 32
3 57 3
3 61 60
2 27 52
2 71 40
3 84 48
2 11 48
2 13 54
3 61 63
3 24 42
4 26 54
3 78 64
3 25 77
3 27 4
3 80 75
3 90 60
3 0 23
1 90 88
1 19 49
3 93 25
1 48 51
1 87 82
3 29 59
3 83 86
3 37 67
3 36 9
2 30 9
2 25 51
3 73 70
4 85 64
3 39 64
1 52 3
4 76 32
3 30 67
2 37 4
3 71 92
4 17 75
4 38 0
2 47 73
2 57 59
2 92 50
1 78 2
1 47 31
4 26 61
1 92 98
1 77 21
4 71 90
4 79 80
2 86 79
1 63 36
3 9 28
2 66 59
1 27 58
2 71 84
1 35 29
2 3 58
1 15 82
1 3 61
1 42 47
1 55 62
2 31 71
1 58 38
3 87 17
3 99 40
4 72 27
3 96 82
1 94 98
2 82 53
1 2 47
0 0 0
AC output:

Code: Select all

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0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1
1
1
-1
0
1
1
1
1
-1
1
-1
1
0
-1
0
1
1
-1
1
0
0
1
1
1
0
1
1
1
1
-1
0
0
0
-1
-1
1
0
0
1
-1
1
0
0
0
-1
1
1
1
-1
1
-1
1
-1
1
1
0
1
0
1
0
1
1
-1
1
1
1
0
0
1
0
-1
-1
1
-1
0
0
-1
0
-1
1
-1
-1
-1
0
0
-1
0
0
1
1
-1
0
-1
0
1
0
-1
-1
0
-1
0
-1
0
-1
-1
-1
1
1
0
0
-1
-1
0
0
0
0
0
-1
0
0
0
1
1
0
0
-1
-1
0
1
-1
0
0
-1
1
-1
1
1
0
-1
1
0
1
0
1
1
1
0
-1
1
0
0
1
-1
0
1
-1
-1
0
-1
1
1
0
0
0
0
0
0
0
-1
-1
1
1
0
1
1
-1
-1
0
0
0
0
0
0
0
0
-1
-1
1
0
0
-1
-1
1
-1
-1
-1
-1
-1
1
1
0
1
-1
-1
-1

Re: 10158 - War

Posted: Thu Jul 10, 2014 10:49 pm
by Rocker3011
hello i am having big trouble with this problem due to its conditions i am trying the cases bryanfry provided and i have errors in some of them, but i really dont know what can lead up to them, since all combinations i try by myself seem to be ok, please somebody check my code, thank you!

Code: Select all

#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <cstring>
#include <set>
using namespace std;

vector <int> enemigo[10005];
int parent[10005];
bool marked[10005];

set <int> enemies[10005];

void init(int &n){
   
    for (int i=0;i<n;++i)
        parent[i]=i;
   
    }
   
   
int Finda (int x){

    if (x==parent[x])
        return x;
       
   
    return parent[x]=Finda( parent[x] );

}

bool Finde(int x, int y){

    if (x==parent[x]){
       
        set <int> :: iterator it;
       
        it = enemies[x].find(y);
       
        if (*it==y)
            return true;
           
        else
            return false;
             
       
    }
   
    return (Finde(parent[x],y) );

}

void Union (int x, int y){

    int xroot=Finda(x);
    int yroot=Finda(y);
   
    parent[yroot]=xroot;
   
    memset(marked,0,sizeof(marked));
   
    for (int i=0;i<enemigo[xroot].size();++i){
        marked[Finda(enemigo[xroot][i])]=true;
    }
   
    for (int i=0;i<enemigo[yroot].size();++i){
       
        int rat= Finda(enemigo[yroot][i]);
        if (marked[rat]) continue;
       
       enemigo[xroot].push_back(rat);
       enemies[xroot].insert(rat);
    }
   
   
   

}

void addenemie (int x, int y){

    int xroot=Finda(x);
    int yroot=Finda(y);
    
    
    for (int i=0;i<enemigo[xroot].size();++i)
    	for (int j=0;j<enemigo[yroot].size();++j)
   			if (enemigo[xroot][i]==enemigo[yroot][j])
   			{
   				printf("-1\n");
   				return;
   			}
    
    enemigo[xroot].push_back(yroot);
   
    enemies[xroot].insert(yroot);
   
    for (int i=0;i<enemigo[yroot].size();++i){
       
        int root=Finda(enemigo[yroot][i]);
       
        
       
       	if (Finde(xroot,root) || Finde(root,xroot)) continue;
       	
       	Union(xroot,root);
       
    }
}

int main() {
   
    int n;
    scanf("%d",&n);
    init(n);
   
    while (true){
       
        int operacion,a,b;
        scanf("%d %d %d",&operacion,&a,&b);
       // cout<<"peo"<<endl;
        if (operacion==0 && a==0 && b==0)
            return 0;
       
        if (operacion==1){
            if (Finde(Finda(a),Finda(b)) || Finde(Finda(b),Finda(a)) )
                printf("-1\n");
            else
                Union(a,b);
               
                //cout<<parent[a]<<" "<<parent[b]<<endl;
        }
       
        else if (operacion==2){
            if (Finda(a)==Finda(b))
                printf("-1\n");
            else{
                addenemie(a,b);
                addenemie(b,a);
                }
               
        }
       
        else if (operacion==3){
           
            if (Finda(a)==Finda(b))
                printf("1\n");
            else
                printf("0\n");
           
        }
       
        else if (operacion==4){
           
            if (Finde(Finda(a),Finda(b)) || Finde(Finda(b),Finda(a)))
                printf("1\n");
            else
                printf("0\n");
           
        }
       
    }
   
   
    return 0;
}

War problem

Posted: Thu Jul 10, 2014 11:15 pm
by Rocker3011
Hello i am having a hard time with this problem, and i really dont know where it fails, can somebody check my code?

Code: Select all

    #include <iostream>
    #include <cstdio>
    #include <string>
    #include <vector>
    #include <cstring>
    #include <set>
    using namespace std;

    vector <int> enemigo[10005];
    int parent[10005];
    bool marked[10005];

    set <int> enemies[10005];

    void init(int &n){
       
        for (int i=0;i<n;++i)
            parent[i]=i;
       
        }
       
       
    int Finda (int x){

        if (x==parent[x])
            return x;
           
       
        return parent[x]=Finda( parent[x] );

    }

    bool Finde(int x, int y){

        if (x==parent[x]){
           
            set <int> :: iterator it;
           
            it = enemies[x].find(y);
           
            if (*it==y)
                return true;
               
            else
                return false;
                 
           
        }
       
        return (Finde(parent[x],y) );

    }

    void Union (int x, int y){

        int xroot=Finda(x);
        int yroot=Finda(y);
       
        parent[yroot]=xroot;
       
        memset(marked,0,sizeof(marked));
       
        for (int i=0;i<enemigo[xroot].size();++i){
            marked[Finda(enemigo[xroot][i])]=true;
        }
       
        for (int i=0;i<enemigo[yroot].size();++i){
           
            int rat= Finda(enemigo[yroot][i]);
            if (marked[rat]) continue;
           
           enemigo[xroot].push_back(rat);
           enemies[xroot].insert(rat);
        }
       
       
       

    }

    void addenemie (int x, int y){

        int xroot=Finda(x);
        int yroot=Finda(y);
       
       
        for (int i=0;i<enemigo[xroot].size();++i)
           for (int j=0;j<enemigo[yroot].size();++j)
                if (enemigo[xroot][i]==enemigo[yroot][j])
                {
                   printf("-1\n");
                   return;
                }
       
        enemigo[xroot].push_back(yroot);
       
        enemies[xroot].insert(yroot);
       
        for (int i=0;i<enemigo[yroot].size();++i){
           
            int root=Finda(enemigo[yroot][i]);
           
           
           
              if (Finde(xroot,root) || Finde(root,xroot)) continue;
              
              Union(xroot,root);
           
        }
    }

    int main() {
       
        int n;
        scanf("%d",&n);
        init(n);
       
        while (true){
           
            int operacion,a,b;
            scanf("%d %d %d",&operacion,&a,&b);
           // cout<<"peo"<<endl;
            if (operacion==0 && a==0 && b==0)
                return 0;
           
            if (operacion==1){
                if (Finde(Finda(a),Finda(b)) || Finde(Finda(b),Finda(a)) )
                    printf("-1\n");
                else
                    Union(a,b);
                   
                    //cout<<parent[a]<<" "<<parent[b]<<endl;
            }
           
            else if (operacion==2){
                if (Finda(a)==Finda(b))
                    printf("-1\n");
                else{
                    addenemie(a,b);
                    addenemie(b,a);
                    }
                   
            }
           
            else if (operacion==3){
               
                if (Finda(a)==Finda(b))
                    printf("1\n");
                else
                    printf("0\n");
               
            }
           
            else if (operacion==4){
               
                if (Finde(Finda(a),Finda(b)) || Finde(Finda(b),Finda(a)))
                    printf("1\n");
                else
                    printf("0\n");
               
            }
           
        }
       
       
        return 0;
    }


Re: War problem

Posted: Fri Jul 11, 2014 7:12 pm
by brianfry713
Don't double post.

Re: War problem

Posted: Fri Jul 11, 2014 11:28 pm
by Rocker3011
sorry i thought i needed to open another one to get help on it, did not know it was only a thread per problem, now idk how to erase it :(

Re: War problem

Posted: Sat Jul 12, 2014 6:24 pm
by lighted
To erase your post you must login to board then find your post and then look at top right corner of post.
There will be EDIT X ! QUOTE options. Use X option

Re: 10158 - War

Posted: Sun Oct 05, 2014 6:00 pm
by damien_g
@brianfry713

My AC code doesn't exactly produce the same output than yours (the "0" on line 105 is a "1" for me).

My AC output is

Code: Select all

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
-1
0
-1
1
0
0
0
0
-1
0
0
0
0
0
0
0
0
-1
0
0
-1
0
0
0
1
0
0
0
1
0
0
0
0
0
0
0
0
-1
-1
0
-1
0
-1
1
-1
0
1
1
-1
-1
1
0
0
0
-1
0
-1
0
0
0
0
1
0
0
1
1
0
1
1
-1
0
-1
0
0
0
-1
1
0
-1
1
1
0
1
0
0
-1
1
-1
1
0
0
0
-1
1
0
-1
0
0
-1
0
-1
0
0
1
0
-1
1
1
1
0
-1
-1
1
-1
0
-1
0
-1
1
1
0
0
-1
-1
-1
0
0
0
0
1
1
-1
-1
1
0
0
-1
-1
1
0
1
-1
0
-1
0
1
1
1
-1
0
-1
0
0
1
1
0
1
0
-1
-1
-1
-1
1
1
0
-1
0
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-1
1
-1
-1
-1
-1
-1
1
1
0
1
-1
-1
-1
I don't know if there is something "illegal" in your input or something like that.

But thanks, your other inputs/outputs were really useful, this problem was challenging !

Re: 10158 - War

Posted: Thu Mar 19, 2015 12:48 pm
by jddantes
The 105th line is really 1, according to uDebug.

Re: 10158 - War

Posted: Wed Apr 08, 2015 11:13 pm
by brianfry713
I edited my post