Submission #2943150


Source Code Expand

#include <bits/stdc++.h>
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 mp make_pair
#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())
vector<P>edge[1005][1005];
bool used[1005][1005];
int n,m;
void dfs(int x,int y){
	if(used[x][y]) return;
	used[x][y] = 1;
	rep(i,edge[x][y].size()){
		int to = edge[x][y][i].fi;
		int to2 = edge[x][y][i].sc;
		dfs(to,to2);
	}
}
int main(){
	cin>>n>>m;
	repn(i,999) repn(j,999){
		int x = i,y = j;
		if(x<y){
			int z = 0;
			while(x){
				z = z*10+x%10;
				x /= 10;
			}
			x = z;
		}
		else{
			int z = 0;
			while(y){
				z = z*10+y%10;
				y /= 10;
			}
			y = z;
		}
		if(x<y){
			y -= x;
		}
		else{
			x -= y;
		}
		if(x == 0 || y == 0){
			edge[0][0].pb(mp(i,j));
		}
		else{
			edge[x][y].pb(mp(i,j));
		}
	}
	dfs(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 IH19980412
Language C++14 (GCC 5.4.1)
Score 400
Code Size 1383 Byte
Status AC
Exec Time 197 ms
Memory 41984 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 400 / 400
Status
AC × 3
AC × 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 AC 180 ms 41984 KB
02.txt AC 181 ms 41984 KB
03.txt AC 180 ms 41984 KB
04.txt AC 183 ms 41984 KB
05.txt AC 180 ms 41984 KB
06.txt AC 180 ms 41984 KB
07.txt AC 179 ms 41984 KB
08.txt AC 182 ms 41984 KB
09.txt AC 180 ms 41984 KB
10.txt AC 181 ms 41984 KB
11.txt AC 179 ms 41984 KB
12.txt AC 182 ms 41984 KB
13.txt AC 181 ms 41984 KB
14.txt AC 186 ms 41984 KB
15.txt AC 188 ms 41984 KB
16.txt AC 192 ms 41984 KB
s1.txt AC 182 ms 41984 KB
s2.txt AC 185 ms 41984 KB
s3.txt AC 197 ms 41984 KB