Please subscribe to the official Codeforces channel in Telegram via the link: https://t.me/codeforces_official. ×

4T-Shirt's blog

By 4T-Shirt, 7 years ago, In English,
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;
}


Read more »

Tags re, spoj
 
 
 
 

By 4T-Shirt, 8 years ago, In English,
Could anyone else please tell me how to add a friend in CF? I'm puzzled about it.

Read more »

 
 
 
 
  • Vote: I like it  
  • -3
  • Vote: I do not like it  

By 4T-Shirt, 8 years ago, In English,
As the title

Read more »