CodeForces - 1331E Jordan Smiley(图形转换)
生活随笔
收集整理的這篇文章主要介紹了
CodeForces - 1331E Jordan Smiley(图形转换)
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
題目鏈接:點擊查看
題目大意:給出一個 64 * 64 的圖形,現在問點 ( x , y ) 是在圖形內部還是外部
題目分析:很直接的一道題目,如果有耐心但缺乏技術的同學完全可以直接一個一個數著做,只不過萬一有一個數錯了就gg了
補題的時候花了一個多小時去學習了轉換圖形的技術,好在中間沒有出什么岔子,還算順利的把這個題目解決掉了,順便收獲了很多知識
因為最近也是在入門matlab(雖然目前只看到了向量,連循環都還沒接觸),硬是一直百度,最后學會了如何處理圖片
首先我們需要將圖形放到畫圖中進行兩個操作:
這一步比較簡單,接下來利用matlab寫一段小程序將上述圖片提取為 01 矩陣
這個時候得到的每個像素并不是嚴格意義上的01矩陣,而是0~255的一個數值,我們只需要自己規定一個閾值,將0和1區分開來就好了,順便規劃一下在數組中的格式,這里用C++完成就好了
最后就是把處理好的01矩陣扔到二維數組中,剩下的O(1)回答就好了
代碼:
#include<iostream> #include<cstdio> #include<string> #include<ctime> #include<cmath> #include<cstring> #include<algorithm> #include<stack> #include<climits> #include<queue> #include<map> #include<set> #include<sstream> #include<unordered_map> using namespace std;typedef long long LL;typedef unsigned long long ull;const int inf=0x3f3f3f3f;const int N=64;bool maze[N][N]= { {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,0,1,0,0,0,0,0,0,1,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}, {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,0,0,0,1,0,1,0,1,0,1,1,0,1,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}, {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,1,0,1,1,1,0,1,1,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0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1}, {1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1}, {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}, {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}, {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}, {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}, {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}, };int main() { #ifndef ONLINE_JUDGE // freopen("input.txt","r",stdin); // freopen("output.txt","w",stdout); #endif // ios::sync_with_stdio(false);int x,y;scanf("%d%d",&x,&y);if(maze[x][y])puts("OUT");elseputs("IN");return 0; }?
總結
以上是生活随笔為你收集整理的CodeForces - 1331E Jordan Smiley(图形转换)的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: CodeForces - 1332B C
- 下一篇: CodeForces - 1330D D