anonymous No title
C++
clist[30][4][2];
void makeclist(){
    for(int i1 = 0;i1 < 4;i1++){
        for(int i2 = 0;i2 < 4;i2++){
            clist[i1][i2][0] = i1;
            clist[i1][i2][1] = i2;
        }
    }
    for(int i1 = 0;i1 < 4;i1++){
         for(int i2 = 0;i2 < 4;i2++){
            clist[i1 + 4][i2][0] = i2;
            clist[i1 + 4][i2][1] = i1;
        }
    }
    for(int i2 = 0;i2 < 4;i2++){
        clist[8][i2][0] = i2;
        clist[8][i2][1] = i2;
        clist[9][i2][0] = i2;
        clist[9][i2][1] = 3 - i2;
    }
    for(int i1 = 0;i1<3;i1++){
        for(int i2 = 0;i2<3;i2++){
            for(int i3 = 0;i3<2;i3++){
                for(int i4 = 0;i4<2;i4++){
                    clist[10+3*i1+i2][i3+i3+i4][0] = i1+i3;
                    clist[10+3*i1+i2][i3+i3+i4][1] = i2+i4;
                }
            }
        }
    }
    for(int i1 = 1;i1<3;i1++){
        for(int i2 = 1;i2<3;i2++){
            for(int i3 = -1;i3<2;i3+=2){
                for(int i4 = -1;i4<2;i4+=2){
                    clist[16+i1+i1+i2][1+i3+(i4+1)/2][0] = i1+i3;
                    clist[16+i1+i1+i2][1+i3+(i4+1)/2][1] = i2+i4;
                    clist[20+i1+i1+i2][1+i3+(i4+1)/2][0] = i1+(i3+i4)/2;
                    clist[20+i1+i1+i2][1+i3+(i4+1)/2][1] = i2+(i3-i4)/2;
                }
            }           
        }
    }
    clist[27][0][0] = 0;
    clist[27][1][0] = 1;
    clist[27][2][0] = 3;
    clist[27][3][0] = 2;
    clist[28][0][0] = 0;
    clist[28][1][0] = 2;
    clist[28][2][0] = 3;
    clist[28][3][0] = 1;
    clist[29][0][0] = 0;
    clist[29][1][0] = 0;
    clist[29][2][0] = 3;
    clist[29][3][0] = 3;
    clist[27][0][1] = 1;
    clist[27][1][1] = 3;
    clist[27][2][1] = 2;
    clist[27][3][1] = 0;
    clist[28][0][1] = 2;
    clist[28][1][1] = 3;
    clist[28][2][1] = 1;
    clist[28][3][1] = 0;
    clist[29][0][1] = 0;
    clist[29][1][1] = 3;
    clist[29][2][1] = 3;
    clist[29][3][1] = 0;
}
anonymous No title
C++
int clist[30][4][2];
void makeclist(){
    for(int i1 = 0;i1 < 4;i1++){
        for(int i2 = 0;i2 < 4;i2++){
            clist[i1][i2][0] = i1;
            clist[i1][i2][1] = i2;
        }
    }
    for(int i1 = 0;i1 < 4;i1++){
         for(int i2 = 0;i2 < 4;i2++){
            clist[i1 + 4][i2][0] = i2;
            clist[i1 + 4][i2][1] = i1;
        }
    }
    for(int i2 = 0;i2 < 4;i2++){
        clist[8][i2][0] = i2;
        clist[8][i2][1] = i2;
        clist[9][i2][0] = i2;
        clist[9][i2][1] = 3 - i2;
    }
    for(int i1 = 0;i1<3;i1++){
        for(int i2 = 0;i2<3;i2++){
            for(int i3 = 0;i3<2;i3++){
                for(int i4 = 0;i4<2;i4++){
                    clist[10+3*i1+i2][i3+i3+i4][0] = i1+i3;
                    clist[10+3*i1+i2][i3+i3+i4][1] = i2+i4;
                }
            }
        }
    }
    for(int i1 = 1;i1<3;i1++){
        for(int i2 = 1;i2<3;i2++){
            for(int i3 = -1;i3<2;i3+=2){
                for(int i4 = -1;i4<2;i4+=2){
                    clist[16+i1+i1+i2][i3+(i4+1)/2][0] = i1+i3;
                    clist[16+i1+i1+i2][i3+(i4+1)/2][1] = i2+i4;
                    clist[20+i1+i1+i2][i3+(i4+1)/2][0] = i1+(i3+i4)/2;
                    clist[20+i1+i1+i2][i3+(i4+1)/2][1] = i2+(i3-i4)/2;
                }
            }           
        }
    }
    clist[27][0][0] = 0;
    clist[27][1][0] = 1;
    clist[27][2][0] = 3;
    clist[27][3][0] = 2;
    clist[28][0][0] = 0;
    clist[28][1][0] = 2;
    clist[28][2][0] = 3;
    clist[28][3][0] = 1;
    clist[29][0][0] = 0;
    clist[29][1][0] = 0;
    clist[29][2][0] = 3;
    clist[29][3][0] = 3;
    clist[27][0][1] = 1;
    clist[27][1][1] = 3;
    clist[27][2][1] = 2;
    clist[27][3][1] = 0;
    clist[28][0][1] = 2;
    clist[28][1][1] = 3;
    clist[28][2][1] = 1;
    clist[28][3][1] = 0;
    clist[29][0][1] = 0;
    clist[29][1][1] = 3;
    clist[29][2][1] = 3;
    clist[29][3][1] = 0;
}
anonymous No title
C++
#include<bits/stdc++.h>
#include<time.h>
using namespace std;
int lastx,lasty;
int lastpiece = -1;
int llastpiece = -1;
bool notloseflag = false;
stack<int> putp;
stack<int> putx;
stack<int> puty;
bool piece[16];
bool cantgive[8];
int field[4][4];
int clist[10][4][2];
void putpiece(int y,int x,int piecenum){
    putx.push(x);
    puty.push(y);
    putp.push(piecenum);
    field[y][x] = piecenum;
    piece[piecenum] = false;
}
void deletepiece(){
    piece[putp.top()] = true;
    field[puty.top()][putx.top()] = -1;
    lastx = putx.top();
    lasty = puty.top();
    llastpiece = lastpiece;
    lastpiece = putp.top();
    putx.pop();
    puty.pop();
    putp.pop();
}
vector<int> binx(int a){
    vector<int> ret = {0,0,0,0};
    int cnt = 0;
    while(cnt<4){
        ret[cnt]=a%2;
        a/=2;
        cnt++;
    }
    return ret;
}
vector<int> binkai(int a){
    vector<int> ret = {0,0,0,0};
    int cnt = 0;
    while(cnt<4){
        ret[cnt]=a%2+a%2-1;
        a/=2;
        cnt++;
    }
    return ret;
}
void check(){
    for(int i1 = 0;i1<8;i1++){
        cantgive[i1] = false;
    }
    for(int i1 = 0;i1<10;i1++){
        int sum[4] = {0,0,0,0};
        bool spaceflag = false;
        for(int i2 = 0;i2<4;i2++){
            int cpiece = field[clist[i1][i2][0]][clist[i1][i2][1]];
            if(cpiece != -1){
                vector<int> tmp = binkai(cpiece);
                for(int i3 = 0;i3<4;i3++){
                    sum[i3] += tmp[i3];
                }
            }else{
                if(spaceflag){
                    break;
                }
                spaceflag = true;
            }
        }
        if(!spaceflag){
            continue;
        }
        for(int i2 = 0;i2<4;i2++){
            if(sum[i2] == 3){
                cantgive[i2+i2+1] = true;
            }
            if(sum[i2] == -3){
                cantgive[i2+i2] = true;
            }
        }
    }
}
bool putcheck(int nowhave){
    vector<int> tmp = binx(nowhave);
    for(int i1 = 0;i1<4;i1++){
        if(cantgive[i1+i1+tmp[i1]]){
            return true;
        }
    }
    return false;
}
bool putedcheck(){
    for(int i1 = 0;i1<10;i1++){
        int tmp[4] = {0,0,0,0};
        for(int i = 0;i<4;i++){
            if(field[clist[i1][i][0]][clist[i1][i][1]]==-1){
                for(int j = 0;j<4;j++){
                    tmp[j] = 5;
                }
                break;
            }
            vector<int> tmpp = binx(field[clist[i1][i][0]][clist[i1][i][1]]);
            for(int j = 0;j<4;j++) tmp[j]+=tmpp[j];
        }
        for(int i = 0;i<4;i++) if(tmp[i]==0 || tmp[i]==4) return true;
    }
    return false;
}
void ittedume(){
    for(int i1 = 0;i1<16;i1++){
        if(!piece[i1])continue;
        for(int i2 = 0;i2<4;i2++){
            for(int i3 = 0;i3<4;i3++){
                if(field[i2][i3] != -1)continue;
                putpiece(i2,i3,i1);
                if(putedcheck()){
                    deletepiece();
                    llastpiece = -1;
                    return;
                }
                deletepiece();
            }
        }
    }
}
void makeclist(){
    for(int i1 = 0;i1 < 4;i1++){
        for(int i2 = 0;i2 < 4;i2++){
            clist[i1][i2][0] = i1;
            clist[i1][i2][1] = i2;
        }
    }
    for(int i1 = 0;i1 < 4;i1++){
         for(int i2 = 0;i2 < 4;i2++){
            clist[i1 + 4][i2][0] = i2;
            clist[i1 + 4][i2][1] = i1;
        }
    }
    for(int i2 = 0;i2 < 4;i2++){
        clist[8][i2][0] = i2;
        clist[8][i2][1] = i2;
        clist[9][i2][0] = i2;
        clist[9][i2][1] = 3 - i2;
    }
}
bool iswin(int nowhave,int nowdepth){
    check();
    if(putcheck(nowhave)){
        return true;
    }
    if(nowdepth == 0){
        return false;
    }
    for(int i1 = 0;i1<4;i1++){
        for(int i2 = 0;i2<4;i2++){
            if(field[i1][i2] != -1){
                continue;
            }
            putpiece(i1,i2,nowhave);
            for(int i3 = 0;i3<16;i3++){
                if(!piece[i3]){
                    continue;
                }
                if(!iswin(i3,nowdepth - 1)){
                    deletepiece();
                    return true;
                }
            }
            deletepiece();
        }
    }
    return false;
}
int main(){
    makeclist();
    for(int i = 0;i<16;i++){
        piece[i] = true;
    }
    int nokori = 0;
    for(int i1 = 0;i1 < 4;i1++){
        for(int i2 = 0;i2 < 4;i2++){
            cin >> field[i1][i2];
            piece[field[i1][i2]] = false;
            if(field[i1][i2] == -1){
                nokori++;
            }
        }
    }
    int youhave;
    clock_t startt,endt;
    cin >> youhave;
    for(int i = 0;i<nokori;i++){
        lastpiece = -1;
        llastpiece = -1;
        bool iwillwin;
        if(i%2 == 0){
            startt = clock();
            iwillwin = iswin(youhave,i);
            endt = clock();
        }else{
            startt = clock();
            iwillwin = iswin(youhave,i);
            endt = clock();
            if(i == 1){
                putpiece(lasty,lastx,lastpiece);
                check();
                for(int i3 = 0;i3<16;i3++){
                    if(!piece[i3]){
                        continue;
                    }
                    if(!putcheck(i3)){
                        lastpiece = i3;
                        break;
                                            }
                }
                deletepiece();
            }
        }
        cout << "depth = " << i + 1 << " ";
        printf("%f", (double)(endt - startt) / CLOCKS_PER_SEC);
        cout << "sec" << endl;
        if(iwillwin && i%2 == 0){
            if(i == 0){
                ittedume();
            }
            cout << "win " << endl;
            cout << "put " << lastpiece << " (" << lasty << "," << lastx << ") ";
            cout << "give " << llastpiece << endl;
            return 0;
        }else if(iwillwin || i%2 == 0){
            if(i%2 == 0){
                cout << "notwin" << endl;
            }else{
                cout << "notlose" << endl;
                cout << "put " << lastpiece << " (" << lasty << "," << lastx << ") ";
                cout << "give " << llastpiece << endl;
            }
        }else{
            cout << "lose" << endl;
            return 0;
        }
        cout << endl;
    }
    return 0;
}
anonymous No title
C++
#include<bits/stdc++.h>
using namespace std;

vector<int> uselist[4][4];
bool piece[17];
int field[5][4];
int clist[10][4][2];
stack<int> putp;
stack<int> putx;
stack<int> puty;
vector<int> binex(int a){
    vector<int> ret = {0,0,0,0};
    int cnt = 0;
    while(a>0){
        ret[cnt]=a%2;
        a/=2;
        cnt++;
    }
    return ret;
}
bool check(vector<int> cclist){
    for(int i1 = cclist.size() - 1;i1 >= 0;i1--){
        int now = cclist[i1];
        int tmp[4] = {0,0,0,0};
        for(int i = 0;i<4;i++){
            if(field[clist[now][i][0]][clist[now][i][1]]==-1){
                for(int j = 0;j<4;j++){
                    tmp[j] = 5;
                }
                break;
            }
            vector<int> tmpp = binex(field[clist[now][i][0]][clist[now][i][1]]);
            for(int j = 0;j<4;j++) tmp[j]+=tmpp[j];
        }
        for(int i = 0;i<4;i++) if(tmp[i]==0 || tmp[i]==4) return true;
    }

    return false;
}
void putpiece(int y,int x,int piecenum){
    putx.push(x);
    puty.push(y);
    putp.push(piecenum);
    field[y][x] = piecenum;
    piece[piecenum] = false;
}
void deletepiece(){
    piece[putp.top()] = true;
    field[puty.top()][putx.top()] = -1;
    putx.pop();
    puty.pop();
    putp.pop();
}
int iswin(int nowhave,int nowdepth){
    if(nowdepth == 0){
        return -1;//0だった
    }
    bool drawflag = false;
    for(int i1 = 0;i1 < 4;i1++){
        for(int i2 = 0;i2 < 4;i2++){
            if(field[i1][i2] == -1){
                deletepiece();
                putpiece(i1,i2,nowhave);
            }else continue;
            if(check(uselist[i1][i2])){
                return 1;
            }
            for(int i3 = 0;i3<16;i3++){
                if(!piece[i3])continue;
                for(int i4 = 0;i4<4;i4++){
                    for(int i5 = 0;i5<4;i5++){
                        if(field[i4][i5] == -1){
                            putpiece(i4,i5,i3);
                        }else continue;
                        if(check(uselist[i4][i5])){
                            goto endloop1;
                        }
                        for(int i6 = 0;i6<16;i6++){
                            if(!piece[i6])continue;
                            putpiece(4,3,16);
                            int willwin = iswin(i6,nowdepth-1);
                            if(willwin == -1){
                                deletepiece();
                                goto endloop1;
                            }else if(willwin == 1){
                                deletepiece();
                            /*}else if(willwin == 0){
                                drawflag = true;
                                deletepiece();*/
                            }
                        }
                        deletepiece();
                    }
                }
                /*if(drawflag){
                    return 0;
                }else{*/
                    return 1;
                //}
                endloop1:;
                deletepiece();
            }
            
        }
    }
    /*if(drawflag){
        return 0;
    }else{*/
        return -1;
    //}
}
int main(){
    for(int i1 = 0;i1 < 4;i1++){
        for(int i2 = 0;i2 < 4;i2++){
            clist[i1][i2][0] = i1;
            clist[i1][i2][1] = i2;
            uselist[i1][i2].push_back(i1);
        }
    }
    for(int i1 = 0;i1 < 4;i1++){
         for(int i2 = 0;i2 < 4;i2++){
            clist[i1 + 4][i2][0] = i2;
            clist[i1 + 4][i2][1] = i1;
            uselist[i2][i1].push_back(i1 + 4);
        }
    }
    for(int i2 = 0;i2 < 4;i2++){
        clist[8][i2][0] = i2;
        clist[8][i2][1] = i2;
        clist[9][i2][0] = i2;
        clist[9][i2][1] = 3 - i2;
        uselist[i2][i2].push_back(8);
        uselist[i2][3 - i2].push_back(9);
    }
    for(int i = 0;i<16;i++){
        piece[i] = true;
    }
    for(int i1 = 0;i1 < 4;i1++){
        for(int i2 = 0;i2 < 4;i2++){
            cin >> field[i1][i2];
            piece[field[i1][i2]] == false;
        }
    }
    int youhave;
    int depth;
    cin >> youhave >> depth;
    putpiece(4,3,16);
    int iwillwin = iswin(youhave,depth);
    if(iwillwin == 1){
        cout << "win" << endl;
        while(!putx.empty()){
            cout << puty.top() << putx.top() << endl;
            cout << putp.top() << endl;
            putx.pop();
            puty.pop();
            putp.pop();
        }
    }else if(iwillwin == 0){
        cout << "draw" << endl;
    }else{
        cout << "lose" << endl;
        while(!putx.empty()){
            cout << puty.top() << putx.top() << endl;
            cout << putp.top() << endl;
            putx.pop();
            puty.pop();
            putp.pop();
        }
    }
    return 0;
}
anonymous No title
C++
#include <iostream>
#include <vector>
#include <set>
using namespace std;
// 今のfieldでputplaceにnowpieceを置いたときに勝ちかどうか
bool iswinvec(std::vector<int> a){
    if(a[0]==-1) return false;
    for(int i = 0;i<4;i++) if(a[i]==4 || a[i]==0) return true;
    return false;
}
std::vector<int> binex(int a){
    std::vector<int> ret = {0,0,0,0};
    int cnt = 0;
    while(a>0){
        ret[cnt]=a%2;
        a/=2;
        cnt++;
    }
    return ret;
}
bool iswin(std::vector<std::vector<int>> field,std::pair<int,int> putplace,int nowpiece){
    field[putplace.first][putplace.second]=nowpiece;
    for(int i = 0;i<4;i++){
        std::vector<int> tmp = {0,0,0,0};
        for(int j = 0;j<4;j++){
            if(field[i][j]<0){
                tmp = {-1,0,0,0};
                break;
            }
            std::vector<int> binextmp = binex(field[i][j]);
            for(int k = 0;k<4;k++){
                tmp[k]+=binextmp[k];
            }
        }
        if(iswinvec(tmp)) return true;
    }
    for(int i = 0;i<4;i++){
        std::vector<int> tmp = {0,0,0,0};
        for(int j = 0;j<4;j++){
            if(field[j][i]<0){
                tmp = {-1,0,0,0};
                break;
            }
            std::vector<int> binextmp = binex(field[j][i]);
            for(int k = 0;k<4;k++){
                tmp[k]+=binextmp[k];
            }
        }
        if(iswinvec(tmp)) return true;
    }
    for(int i = 0;i<1;i++){
        std::vector<int> tmp = {0,0,0,0};
        for(int j = 0;j<4;j++){
            if(field[j][j]<0){
                tmp = {-1,0,0,0};
                break;
            }
            std::vector<int> binextmp = binex(field[j][j]);
            for(int k = 0;k<4;k++){
                tmp[k]+=binextmp[k];
            }
        }
        if(iswinvec(tmp)) return true;
    }
    for(int i = 0;i<1;i++){
        std::vector<int> tmp = {0,0,0,0};
        for(int j = 0;j<4;j++){
            if(field[3-j][j]<0){
                tmp = {-1,0,0,0};
                break;
            }
            std::vector<int> binextmp = binex(field[3-j][j]);
            for(int k = 0;k<4;k++){
                tmp[k]+=binextmp[k];
            }
        }
        if(iswinvec(tmp))  return true;
    }
    return false;
}
std::vector<std::vector<int>> put(std::vector<std::vector<int>> field,std::pair<int,int> putplace,int nowpiece){
    field[putplace.first][putplace.second]=nowpiece;
    return field;
}
std::set<int> erase(std::set<int> remainpiece,int piece){
    remainpiece.erase(piece);
    return remainpiece;
}
std::vector<int> solve(std::vector<std::vector<int>> field,std::set<int> remainpiece,int nowpiece,int depth){
    //今おけるところを調べている
    std::vector<std::pair<int,int>> canput;
    for(int i=0;i<4;i++) for(int j=0;j<4;j++) if(field[i][j]<0) canput.push_back(std::make_pair(i,j));
    //今の一手で勝てるかどうかを調べてる
    for(int i=0;i<canput.size();i++){
        if(iswin(field,canput[i],nowpiece)){
            std::vector<int> ret = {1,canput[i].first,canput[i].second};
            //cout << nowpiece << endl;
            return ret;
        }
    }
    if(depth==1){
        std::vector<int> ret = {0,-1,-1};
        return ret;
    }
    std::vector<int> ret = {-1,-1,-1};
    int sign = -1;
    for(int i=0;i<canput.size();i++){
        for(auto itr = remainpiece.begin();itr!=remainpiece.end();itr++){
            std::vector<int> tmptmpret = solve(put(field,canput[i],nowpiece),erase(remainpiece,*itr),*itr,depth-1);
            tmptmpret[0]*=(-1);
            if(tmptmpret[0]==1){
                ret[0]=1;
                ret[1]=canput[i].first;
                ret[2]=canput[i].second;
                ret.push_back(*itr);
                //cout << ret[1] << " " << ret[2] << endl;
                return ret;
            };
            sign = max(tmptmpret[0],sign);
        }
        if(sign>ret[0]) ret[0] = sign;
        //if(ret[0]==1) return ret;
    }
    return ret;
}
int main(){
    std::vector<std::vector<int>> field;
   for(int i = 0;i<4;i++) field.push_back({});
    for(int i = 0;i<4;i++) for(int j = 0;j<4;j++) field[i].push_back(-1);
    for(int i = 0;i<4;i++) for(int j = 0;j<4;j++) std::cin >> field[i][j];
    int nowpiece,depth;
    std::cin >> nowpiece;
    std::cin >> depth;
    std::set<int> remainpiece;
    for(int i = 0;i<16;i++) remainpiece.insert(i);
    for(int i = 0;i<4;i++) for(int j = 0;j<4;j++){
        if(field[i][j]!=-1) remainpiece.erase(field[i][j]);
    }
    remainpiece.erase(nowpiece);
    std::vector<int> result = solve(field,remainpiece,nowpiece,depth);
    std::cout << result[0] << " " << result[1] << " " << result[2] << std::endl;
    if(result.size()==4) cout << result[3] << endl;
}
anonymous No title
C++
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)

typedef long long ll;
const int dx[2] = {1, 0};
const int dy[2] = {0, 1};

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

const int INF = 1e9;

int T[123][123] = {};
ll Cost[123][123] =  {};
int H,W,C;

bool IsIn(int x,int y){
    return 0<=x&&x<H&&0<=y&&y<W;
}
int main() {
    cin>>H>>W>>C;
    rep(i,H)rep(j,W){
        cin>>T[i][j];
        Cost[i][j] = INF;
    }
    Cost[0][0] = 0;
    queue<pair<int,int>> Q;
    Q.push({0,0});
    while(!Q.empty()){
        auto p =  Q.front();
        int x = p.first;
        int y = p.second;
        Q.pop();
        rep(i,2){
            int nx = x + dx[i];
            int ny = y + dy[i];
            if(!IsIn(nx,ny))continue;
            if(T[nx][ny]==1){
                //chmin(Cost[nx][ny], Cost[x][y] + C);
                Cost[nx][ny] = min(Cost[nx][ny], Cost[x][y] + C);
            }
            else{
                Cost[nx][ny] = min(Cost[nx][ny], Cost[x][y]);
                //chmin(Cost[nx][ny], Cost[x][y]);
            }
            Q.push({nx,ny});
        }
    }
    cout<<Cost[H-1][W-1]<<endl;
}
Retired K@PCK No title
C++
#include <bits/stdc++.h>
#define rep(var,cnt) for(int (var)=0; (var)<(int)(cnt); ++(var))
#define REP(var,init,cnt) for(int (var)=(init); (var)<(cnt); ++(var))
#define ran(var,vec) for(auto &(var):(vec))
#define all(v) (v).begin(),(v).end()
#define TF(flag) (flag)?1:0
using namespace std;

using ll = long long;
using ull = unsigned long long;
using pi = pair<ll,ll>;

template<typename T>
using vec = vector<T>;
template<typename T>
using mat = vector<vec<T>>;

template<typename T1,typename T2>
ostream &operator<<(ostream &os, const pair<T1,T2> &p){
  os<<"P("<<p.first<<", "<<p.second<<") ";
  return os;
}

template<typename T1,typename T2>
istream &operator>>(istream &is, pair<T1,T2> &p){
  is>>p.first>>p.second;
  return is;
}

template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v){
  for(int i=0; i<(int)v.size(); ++i){
    os<<v[i]<<(i+1!=v.size()?" ":"");
  }
  return os;
}

template<typename T>
istream &operator>>(istream &is, vector<T> &v){
  for(T &in:v) is>>in;
  return is;
}

// Usual Template End ================================================

// Template End ======================================================
monkukui No title
C++
50 149
45 47 8
36 44 2
27 34 10
47 9 9
9 45 1
4 9 5
29 24 4
28 3 6
10 7 1
9 33 2
29 25 1
35 20 1
47 4 10
49 24 5
16 35 1
39 23 9
7 26 1
45 33 1
19 43 8
11 25 4
17 26 1
23 18 8
28 18 9
24 31 1
40 1 6
17 20 9
42 5 10
39 28 4
10 40 5
9 22 2
4 33 1
17 7 1
6 27 1
24 49 5
40 2 6
48 28 6
4 33 1
23 28 1
37 25 5
12 23 9
5 44 6
45 22 3
18 48 1
16 20 1
19 1 8
39 14 10
37 49 8
33 47 7
24 25 2
39 32 2
43 1 1
36 8 1
44 8 7
37 39 2
23 3 6
44 36 2
6 27 1
32 3 2
32 14 6
11 30 6
14 32 6
22 9 2
25 31 1
9 15 10
48 30 5
29 38 9
11 31 9
4 22 8
17 26 1
38 39 1
47 22 2
21 14 6
1 40 6
38 23 8
12 7 8
1 43 1
30 18 7
1 19 8
36 6 9
44 46 3
31 25 1
38 11 9
47 22 2
48 23 6
37 14 6
48 18 1
48 30 5
17 10 3
13 42 3
48 28 6
46 4 8
32 38 4
4 44 4
10 40 5
25 38 6
8 27 6
23 32 10
28 38 2
16 50 9
1 2 5
39 25 7
19 35 8
7 17 1
36 8 1
44 46 3
4 44 4
8 18 10
29 11 2
18 27 9
18 27 9
29 37 10
3 38 9
35 19 8
33 44 8
38 28 2
37 31 6
26 12 4
17 35 10
46 5 1
28 32 6
31 49 8
45 9 1
4 36 6
4 8 10
24 31 1
38 39 1
26 10 6
41 21 10
39 32 2
46 5 1
39 37 2
3 12 6
26 12 4
8 6 6
11 29 2
31 29 2
37 24 7
50 16 9
23 28 1
22 33 4
35 20 1
32 37 4
39 3 7
33 45 1
3 32 2
40 19 9
25 37 5
45 4 2
37 38 4
monkukui No title
C++
50 100
47 3 6
42 36 9
45 19 10
46 15 5
13 41 2
7 49 9
8 14 9
3 42 3
11 12 5
15 30 2
24 11 4
33 46 10
8 43 7
12 35 4
22 27 10
10 18 2
11 39 6
45 16 1
32 48 4
39 16 6
25 44 7
48 28 4
29 49 3
15 12 5
1 31 3
37 24 8
27 9 2
15 27 6
16 15 9
15 35 5
7 17 8
11 19 4
10 32 10
28 38 8
32 3 4
33 9 8
5 23 7
48 39 7
30 6 5
23 18 7
46 9 2
38 49 8
41 27 9
22 38 3
47 2 4
23 21 6
16 43 8
32 23 2
39 28 10
33 40 4
2 17 2
13 26 3
25 13 10
4 16 1
3 20 4
41 40 3
40 10 10
37 3 10
20 34 3
33 17 7
24 20 6
32 14 9
37 31 10
14 33 5
49 16 7
31 34 8
38 18 9
7 36 2
23 43 9
3 49 4
50 38 10
40 20 8
2 37 1
43 42 7
11 25 7
3 1 4
43 29 4
1 48 7
10 13 6
8 12 8
24 4 3
18 42 5
35 46 5
45 30 10
27 21 4
29 39 8
33 50 7
17 15 9
19 34 3
8 32 3
38 8 8
18 43 4
5 24 6
31 16 1
49 9 5
13 47 6
42 46 10
26 49 7
26 22 6
12 1 5
monkukui No title
C++
50 150
42 43 2
37 49 8
41 26 10
10 13 1
9 33 6
19 4 6
43 23 8
49 3 10
8 38 4
16 10 7
34 24 4
43 18 5
28 6 8
23 32 9
30 15 6
22 38 10
49 9 3
33 40 1
18 25 2
11 39 7
17 15 10
25 16 2
16 19 1
38 24 9
1 31 9
16 15 5
9 7 1
28 39 2
10 36 7
10 40 9
48 46 10
9 32 4
7 17 1
46 24 8
43 2 10
28 38 5
4 24 4
34 20 3
26 30 2
13 47 8
50 7 2
20 24 3
16 49 5
33 14 7
3 2 6
14 44 8
38 41 10
35 46 3
47 23 3
48 31 6
37 2 9
46 9 5
9 28 4
40 38 8
47 3 3
36 42 6
14 8 8
20 3 5
13 41 2
12 15 8
26 13 3
10 32 5
26 49 6
18 10 7
29 39 1
29 48 8
12 28 5
5 24 2
15 46 1
50 38 7
40 20 4
13 25 5
47 2 9
34 21 8
8 43 4
3 1 4
16 39 4
48 1 6
8 12 6
46 42 7
44 25 4
43 12 3
45 19 3
26 22 1
32 14 9
45 16 10
47 30 7
11 12 7
31 13 4
49 29 2
6 25 2
32 48 10
3 44 4
11 25 7
26 33 8
9 27 10
21 23 1
27 41 6
15 35 10
12 1 5
26 39 4
17 33 10
20 8 4
9 20 8
40 41 6
6 26 10
42 9 4
11 19 7
16 31 4
16 43 2
29 43 2
42 3 5
18 38 1
50 33 4
33 28 1
45 30 7
13 49 9
32 16 2
7 36 10
28 48 9
37 31 7
10 23 9
5 23 3
4 16 6
22 27 10
48 39 5
24 11 10
27 19 3
46 33 2
49 7 6
37 46 8
17 2 3
19 12 9
8 32 3
35 12 5
46 29 3
37 24 7
15 27 10
21 27 2
34 19 10
18 23 9
34 31 2
3 37 5
34 46 10
32 3 4
18 42 9
36 24 8
6 30 1
49 38 7
5 37 6
Don't you submit code?
Submit