Изменения рейтингов за последние раунды временно удалены. Скоро они будут возвращены. ×

Блог пользователя 4T-Shirt

Автор 4T-Shirt, 13 лет назад, По-английски
Hi! This is a problem on SPOJ: http://www.spoj.pl/problems/ACS/
Could someone please tell me why my program is always "runtime error ".
Here is my code:
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
using namespace std;
const int rowMax = 1234;
const int colMax = 5678;
int mat[rowMax+1][colMax+1];
char ch[100];
char c;
int a,b;
int main()
{
    int cnt = 0;
    for (int i=1;i<=colMax;i++)    mat[0][i] = i;
    for (int i=1;i<=rowMax;i++) mat[i][0] = i;
    for (int i=1;i<=rowMax;i++)
        for (int j=1;j<=colMax;j++)
        {
            mat[i][j] = cnt + 1;
            cnt ++;
        }
        while (gets(ch))
        {
            if (strlen(ch)==0)
            {
            }
            else if (ch[0]=='R')
            {
                sscanf(ch,"%c %d %d",&c,&a,&b);
                mat[a][0] = b;mat[b][0] = a;
            }
            else if (ch[0] == 'C')
            {
                sscanf(ch,"%c %d %d",&c,&a,&b);
                mat[0][a] = b;mat[0][b] = a;
            }
            else if (ch[0] == 'Q')
            {
                sscanf(ch,"%c %d %d",&c,&a,&b);
                int row = 1,col=1;
                while (mat[row][0] != a )    row++;
                while (mat[0][col] != b )    col++;
                printf("%d\n",mat[row][col]);
            }
            else if (ch[0] == 'W')
            {
                sscanf(ch,"%c %d",&c,&a);
                int row = (a-1)/colMax + 1;
                int col = a - (row-1)*colMax;
                printf("%d %d\n",mat[row][0],mat[0][col]);
            }
        }
        return 0;
}


Полный текст и комментарии »

Теги re, spoj
  • Проголосовать: нравится
  • 0
  • Проголосовать: не нравится

Автор 4T-Shirt, 13 лет назад, По-английски
  • Проголосовать: нравится
  • 0
  • Проголосовать: не нравится