Submission #6405573
Source Code Expand
#include <bits/stdc++.h>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <iostream>
#include <bitset>
#include <cassert>
#include <queue>
#include <random>
#include <stack>
#include <iomanip>
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define repf(i, a, b) for (ll i = (ll)a; i < (ll)b; i++)
#define repr(i, a, b) for (ll i = (ll)a; i > (ll)b; i--)
#define repv(x, arr) for (auto &x : arr)
#define all(v) (v).begin(), (v).end()
#define vec(name, num) vector<ll> name((num), 0);
#define mp(a, b) make_pair(a, b)
#define op(i) cout << (i) << endl;
#define F first
#define S second
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<int> vii;
typedef vector<vii> vvii;
const ll mod = 1e9 + 7;
const int infi = 2147483600;
const ll infl = 1e17;
struct REV{
vector<int> L;
int N;
void __init__(int sz){
N=sz;
L.resize(N + 1,0);
repf(i,1,N+1){
L[i] = re(i);
}
}
int re(int i){
string s = to_string(i);
int res=0;
rep(k,s.size()){
res += s[s.size()-k-1] - '0';
res *= 10;
}
return res/10;
}
int get(int x){
return L[x];
}
};
REV rev;
void check(int x,int y,set<pii>& visited,vvii& ans){
if (ans[x][y]!=-1)
return;
int xx=x, yy = y;
if (xx<yy)
xx = rev.get(xx);
else
yy = rev.get(yy);
if (xx<yy)
yy -= xx;
else
xx -= yy;
if (visited.count(mp(xx,yy))==1){
ans[xx][yy] = 1;
return;
}
visited.insert(mp(x, y));
check(xx, yy,visited,ans);
ans[x][y] = ans[xx][yy];
return;
}
int n, m;
int main()
{
rev.__init__(1000);
cin >> n >> m;
vvii ans(1000, vii(1000, -1));
rep(i, 1000) ans[i][0] = 0;
rep(j, 1000) ans[0][j] = 0;
repf(x,1,n+1){
repf(y,1,m+1){
set<pii> visited;
check(x, y,visited,ans);
}
}
int res = 0;
repf(x,1,n+1){
repf(y,1,m+1){
if (ans[x][y])
res++;
}
}
cout << res << endl;
}
Submission Info
Submission Time |
|
Task |
D - うほょじご |
User |
gratan |
Language |
C++14 (GCC 5.4.1) |
Score |
400 |
Code Size |
2368 Byte |
Status |
AC |
Exec Time |
98 ms |
Memory |
4224 KB |
Judge Result
Set Name |
Sample |
All |
Score / Max Score |
0 / 0 |
400 / 400 |
Status |
|
|
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 |
AC |
94 ms |
4224 KB |
02.txt |
AC |
3 ms |
4224 KB |
03.txt |
AC |
56 ms |
4224 KB |
04.txt |
AC |
4 ms |
4224 KB |
05.txt |
AC |
4 ms |
4224 KB |
06.txt |
AC |
3 ms |
4224 KB |
07.txt |
AC |
3 ms |
4224 KB |
08.txt |
AC |
91 ms |
4224 KB |
09.txt |
AC |
5 ms |
4224 KB |
10.txt |
AC |
77 ms |
4224 KB |
11.txt |
AC |
98 ms |
4224 KB |
12.txt |
AC |
3 ms |
4224 KB |
13.txt |
AC |
3 ms |
4224 KB |
14.txt |
AC |
29 ms |
4224 KB |
15.txt |
AC |
3 ms |
4224 KB |
16.txt |
AC |
39 ms |
4224 KB |
s1.txt |
AC |
3 ms |
4224 KB |
s2.txt |
AC |
3 ms |
4224 KB |
s3.txt |
AC |
11 ms |
4224 KB |