General
 
 
# Author Problem Lang Verdict Time Memory Sent Judged  
115772376 Practice:
start_code_end
1B - 9 GNU C++17 Runtime error on test 6 62 ms 3672 KB 2021-05-09 12:08:44 2021-05-09 12:08:44
 
 
→ Source
#include <bits/stdc++.h>
using namespace std;

void print_alpnum(string a, long long int pos)
{
    string row, col, col2, fin_col = "", ans = "";
    row = a.substr(1,pos-1);
    col = a.substr(pos+1,a.size());
    col2.assign(col);
    long long int value = stoi(col), power = 0;
    while (pow(26,power) < value)
    {
        power++;
    }

    for (long long int i = 0; i < power; i++)
    {
        long long int v, temp;
        char alph;
        if (value % 26 == 0 && i == 0)
        {
            fin_col = fin_col + 'Z';
            value = value - 26;
        }
        else if (i == 0)
        {
            v = value % 26;
            value = value - v;
            alph = v-1 + 'A'; 
            fin_col = fin_col + alph;
        }
        else
        {
            v = value / 26;
            temp = v % 26;
            alph = temp-1 + 'A';
            fin_col = fin_col + alph;
            value = v - temp;
        }
    }
    reverse(fin_col.begin(),fin_col.end());
    fin_col = fin_col + row;
    cout << fin_col << endl;

}

void print_rowcol(string a)
{
    string col = "", row = "R";
    long long int row_pos = 0;
    for (long long int i = 0; isdigit(a[i]) == 0; i++)
    {
        col = col + a[i];
        if (isdigit(a[i+1]) != 0)
        {
            row_pos = i + 1;
        }
    }

    row = row + a.substr(row_pos,a.size());
    row = row + 'C';

    long long int col_value = 0;
    for (long long int i = row_pos-1; i >= 0; i--)
    {
        long long int ind_val = a[row_pos-1-i] - 'A' + 1;
        col_value += pow(26,i) * ind_val;
    }

    row = row + to_string(col_value);

    cout << row << endl;
}

int main()
{
    long long int n;
    cin >> n;
    while (n--)
    {
        string cell;
        cin >> cell;

        if (cell[0] == 'R' || cell[0] == 'C')
        {
            long long int pos = cell.find('C');
            print_alpnum(cell,pos);
        }
        else
        {
            print_rowcol(cell);
        }
    }
}
 
 
?
Time: ? ms, memory: ? KB
Verdict: ?
Input
?
Participant's output
?
Jury's answer
?
Checker comment
?
Diagnostics
?
Click to see test details