Submission #4629326


Source Code Expand

Copy
#include<algorithm>
#include<complex>
#include<ctype.h>
#include<iomanip>
#include<iostream>
#include<fstream>
#include<map>
#include<math.h>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<stdio.h>
#include<string>
#include<string>
#include<vector>

using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

#define ALL(v) (v).begin(), (v).end()

struct Point{
    ll x;
    ll y;
    Point(){}
    Point(ll a, ll b){
        x = a;
        y = b;
    }

    bool operator<(const Point &another) const
    {
        if(x == another.x){
            return y < another.y;
        }else{
            return x < another.x;
        }
    }

    string ToString(){
        stringstream ss;
        ss << "point " << x << " " << y;
        return ss.str();
    }
};

bool used[1005][1005];
ll N, M;
map<Point, vector<Point> > mp;

void dfs(Point point){
    ll x = point.x;
    ll y = point.y;
    
	if(used[x][y]) return;
	used[x][y] = 1;

    auto list = mp[point];
    for(auto p : list){
        dfs(p);
    }
}

ll rev(ll a){
    string s = to_string(a);
    reverse(ALL(s));
    return stoi(s);
}

int main(){
	cin >> N >> M;

	repn(i,999) repn(j,999){
		int x = i,y = j;
		if(x<y){
			x = rev(x);
		}
		else{
            y = rev(y);
		}
		if(x<y){
			y -= x;
		}
		else{
			x -= y;
		}
		if(x == 0 || y == 0){
            mp[Point(0, 0)].push_back(Point(i, j));
			// edge[0][0].pb(make_pair(i,j));
		}
		else{
            mp[Point(x, y)].push_back(Point(i, j));
			// edge[x][y].pb(make_pair(i,j));
		}
	}
	dfs(Point(0, 0));
	int ans = 0;
	repn(i,N) repn(j,M){
		if(!used[i][j]) ans++;
	}
	cout<<ans<<endl;
}

Submission Info

Submission Time
Task D - うほょじご
User peroon
Language C++14 (GCC 5.4.1)
Score 400
Code Size 2132 Byte
Status
Exec Time 1441 ms
Memory 106880 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 400 / 400
Status
× 3
× 19
Set Name Test Cases
Sample s1.txt, s2.txt, s3.txt
All 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, s1.txt, s2.txt, s3.txt
Case Name Status Exec Time Memory
01.txt 1434 ms 104832 KB
02.txt 1385 ms 104832 KB
03.txt 1430 ms 104832 KB
04.txt 1406 ms 104832 KB
05.txt 1433 ms 104832 KB
06.txt 1433 ms 104832 KB
07.txt 1441 ms 104832 KB
08.txt 1410 ms 104832 KB
09.txt 1420 ms 104832 KB
10.txt 1418 ms 104832 KB
11.txt 1440 ms 104832 KB
12.txt 1440 ms 104832 KB
13.txt 1412 ms 104832 KB
14.txt 1420 ms 104832 KB
15.txt 1426 ms 104832 KB
16.txt 1440 ms 104832 KB
s1.txt 1438 ms 104832 KB
s2.txt 1436 ms 104832 KB
s3.txt 1430 ms 106880 KB