หน้าแรก
 การบ้าน
  C/C++ new
  Java new
  Windows Phone
  แจ้งเรื่องที่ต้องการ
 บทความ
  .NET
  Android
  Blackberry
  C++Builder
  Delphi
  Java
  Mobile
  Open Source
  Pocket PC
  Visual Basic
  Web
  Windows Phone
  Others
 แบบเรียนฟรี
  ASP
  ASP.NET Webmatrix
  C++
  eVB
  J2ME
  Java
  PHP
 ซอร์สโค้ด
  Android
  ASP
  C++
  VC++
  CGI-Perl
  Delphi
  Java
  jQuery
  PHP
  Visual Basic
  .NET
 บริการจากเรา
  เปิดท้าย... ขายโค้ด
  Freeware
  อัตราค่าโฆษณา
  รายชื่อลูกค้า
  สถิติผู้เข้าเว็บ
 ดาว์นโหลด
 ค้นหาข้อมูล
 กระดานสนทนา
  .NET
  C/C++
  Delphi
  Java
  Palm/PocketPC
  Visual Basic
  Web
  อื่นๆ
 กระดานงาน
 ลิงค์เว็บ
 เกี่ยวกับผม
 อัตราค่าโฆษณา
Social Network

Facebook  Twitter  YouTube
 New Article
 Webboard
 Freelanceboard
Freeware
โปรแกรมเบอร์ดี (BerDee)
โปรแกรมเบอร์ดี (Android)
เกมส์เป่ายิ้งฉุบ
เกมส์เป่ายิ้งฉุบ(Android)
WebcamMonitor
WebcamMonitor(Windows)
scSendMail
scSendMail(Windows)
MSN Caption
MSN Caption(Windows)
  Freelance comment
  ติดต่อสอบถามมาได้ตลอดนะ...
2015-07-29 13:35:58
  ถ้าผมต้องการเว็บที่พัฒน...
2015-01-18 15:33:54
  ถ้าผมต้องการเว็บที่พัฒน...
2015-01-18 15:32:51
  ติดต่อสอบถามเข้ามาได้นะ...
2014-01-06 12:47:38
  ถ้ายังหาคนสอนไม่ได้ ก็ลอ...
2013-07-06 01:04:37
  สนใจส่งขอบเขตมาคุยราคาก...
2013-03-24 18:54:20
  ถ้ายังไม่มีคนรับงานติดต...
2012-12-16 19:18:14
  สนใจคะ ติดต่อ 0905076277...
2012-11-12 11:07:46
  รับทำโปรเจ็คนักศึกษาหรื...
2012-10-29 03:10:46
  sukit_te34@hotmail.com...
2012-10-29 03:09:36
  Webboard comment
  มาส่อง...
2024-08-19 15:45:12
  ช่วยเขียนโปรเจค: การควบค...
2024-08-07 09:13:31
  เขียนโปรแกรมภาษาจาวา
1.โ...

2023-09-12 11:40:28
  ต้องลอง debug ดูเองครับ
ไล่...

2023-06-08 18:03:06
  ร้านค้าแห่งหนึ่ง จะต้องน...
2021-09-21 08:47:08
  จงเขียนโปรแกรมดำเนินการ...
2021-05-07 15:06:11
  จงเขียนโปรแกรมสำหรับคำน...
2021-03-09 14:21:45
  ขอดู...
2021-01-04 23:56:45
  ขอโค้ดเพื่อทำการเรียนกา...
2020-12-09 23:02:09
  แล้ว ?...
2020-12-09 10:56:34
  Homework comment
  ขอโฟชาร์ตของโปรแกรมคำนว...
2025-02-27 13:31:36
  เขียนโปรแกรมเพื่อรับค่า...
2022-02-24 10:45:17
  จากโค้ดนี้อะครับ พอดีลอง...
2021-03-22 01:22:39
  จากโค้ดนี้อะครับ พอดีลอง...
2021-03-22 01:22:39
  โจทย์การบ้าน c++ เขียนรูปแ...
2020-04-06 11:01:33
  แบบนี้ขอเป็น ภาษา php หน่อย...
2019-09-18 14:36:34
  ผมไม่อยากให้คุณได้คะแนน...
2019-04-27 01:29:07
  อาจารย์เขาบอกแนวข้อสอบม...
2019-04-27 00:44:29
  ขอสอบถามการเขียน c++ ครับ เ...
2018-04-02 12:19:21
  โค้ดตัวอย่างศึกษาให้เข้...
2017-11-26 14:50:05
  Article comment
  Wanting to elevate your website traffic? Our smart platform channels i...
2025-08-31 21:15:16
  เท่าที่อ่าน error คือพื้นที่...
2022-03-23 13:56:48
  เรียน สอบถามปัญหา กับ อ.คร...
2022-01-24 17:39:49
  ต้องการ ให้เขียน โปรแกรม ...
2019-12-09 11:39:58
  รับเขียน arx จาก vc++ 2017 ล็อคโปร...
2019-09-19 09:48:09
  ทำการ register ไฟล์ที่ชื่อ mswinsck.oc...
2019-09-17 14:05:56
  ใน vb 6 ไม่มี component winsock เลยค่ะ ส...
2019-09-03 10:31:02
  รบกวนขอสอบถามหน่อยนะครั...
2019-03-04 05:31:04
  สามารถนำตัวหนังสือจากภา...
2018-12-25 08:54:32
  มีcode ของ VB ไหมค่ะ ถ้ามีรบกว...
2017-09-28 16:50:02
  9Mcode comment

Link Exchange

อัตราค่าโฆษณา
 
 Webboard

- - - - - - - - - - - - - - ผู้ให้การสนับสนุน- - - - - - - - - - - - - -

กระทู้ #2963 [C] (จาก IP: 202.28.27.3)

ช่วยแกะ code นี้ให้หน่อยนะครับ

ช่วยแกะให้หน่อยนะครับขอวิธีคำนวณก็ได้ครับ คือผมอ่าน code แล้วงงมากๆ

#include<algorithm>
#include<bitset>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<list>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<string>
#include<utility>
#include<vector>
using namespace std;
int rt(int x,vector<int>& fat)//การเรียกโมดูล
{
if(x==fat[x])/*x เท่ากับ fat[x] หรือไม่ ถ้าใช่ คืนค่า X ถ้าไม่ให้ คืนค่า fat[x] */
return x;
else
return fat[x]=rt(fat[x],fat);
}
string check(string s,string pres)
{

int c=s.length();



int star=-1;
for(int j=0;j<c&&star==-1;j++)
if(s[j]=='S')
star=j;

vector<int> fat(c);
vector<int> pre(10,-1);
for(int j=0;j<c;j++)
{
if(s[j]>='1'&&s[j]<='9')
{
if(pre[s[j]-'0']==-1)
{
pre[s[j]-'0']=j;
fat[j]=j;
}
else
fat[j]=pre[s[j]-'0'];
}
else
fat[j]=j;
}
for(int j=0;j<c-1;j++)
{
if(s[j]=='.'||s[j+1]=='.')continue;
int fa=rt(j,fat),fb=rt(j+1,fat);
if(fa==fb)
return "fuck";
fat[fa]=fb;
}

string ret=s;
vector<int> bj(c,-1);
int newind=1;
for(int j=0;j<c;j++)
{
if(s[j]=='.')continue;
int cnn=0;
if(j&&s[j-1]!='.')cnn++;
if(j!=c-1&&s[j+1]!='.')cnn++;
if(pres[j]!='.')cnn++;

if(cnn==1)
{
int jf=rt(j,fat);
if(jf==rt(star,fat))
ret[j]='S';
else if(bj[jf]==-1)
{
ret[j]='0'+newind;
bj[jf]=newind++;
}
else
ret[j]='0'+bj[jf];
}
else if(cnn==2)
ret[j]='0';
else
return "fuck";
}

for(int j=0;j<c-1;j++)
if(((ret[j]>='1'&&ret[j]<='9')||ret[j]=='S')&&((ret[j+1]>='1'&&ret[j+1]<='9')||ret[j+1]=='S'))
return "fuck";
vector<int> ed(newind,0);
for(int j=0;j<c;j++)
{
if(ret[j]>='1'&&ret[j]<='9')
ed[ret[j]-'0']++;
}
for(int j=1;j<newind;j++)
{
if(ed[j]!=2)
return "fuck";
}
return ret;
}
int main()
{
int r,c,cas=1;
while(cin>>r>>c,(r||c))
{
vector<string> mat(r+1,string(c,'.'));
for(int i=1;i<=r;i++)cin>>mat[i];
vector<map<string,pair<int,string> > > dp(r+1);
dp[0]["S"+string(c-1,'.')].first=0;
for(int i=1;i<=r;i++)
{
for(map<string,pair<int,string> >::iterator it=dp[i-1].begin();it!=dp[i-1].end();it++)
{
string row=it->first;
int num=it->second.first;
//cout<<i-1<<" "<<row<<" "<<it->second.second<<endl;
string now=string(c,'?');
for(int j=0;j<c;j++)
{
if(row[j]=='S'||(row[j]>='1'&&row[ j]<='9'))
now[j]=row[j];
else if(row[j]=='0')
now[j]='.';
}
for(int j=0;j<c;j++)
{
if(j&&row[j]=='0'&&now[j-1]=='?')
now[j-1]='.';

if(j!=c-1&&row[j]=='0'&&now[j+1]=='?')
now[j+1]='.';
}

vector<int> pos;
for(int j=0;j<c;j++)
{
if(now[j]=='?')
pos.push_back(j);
}
int size=pos.size();
for(int s=0;s<(1<<size);s++)
{
string t=now;
for(int j=0;j<size;j++)
{
if(s&(1<<j))
t[pos[j]]='C';
else
t[pos[j]]='.';
}
bool contt=0;
for(int j=0;!contt&&j<c;j++)
if(mat[i][j]=='#'&&t[j]!='.')
contt=1;
if(contt)
continue;


t=check(t,row);

if(t=="fuck")
continue;
int tnum=num;
for(int j=0;j<c;j++)
if(t[j]!='.')
tnum++;
if(dp[i].find(t)==dp[i].end()||dp[i][t].first<tnum)
{
dp[i][t].first=tnum;
dp[i][t].second=row;
}
}
}

}
int haha=0;
string bst;
for(map<string,pair<int,string> >::iterator it=dp[r].begin();it!=dp[r].end();it++)
{
string row=it->first;
int num=it->second.first;
int fh=1;
for(int j=0;fh&&j<c;j++)
if(row[j]>='1'&&row[j]<='9')
fh=0;
if(fh&&row[c-1]=='S'&&haha<num)
{
haha=num;
bst=row;
}
}
for(int i=r;i>=1;i--)
{
for(int j=0;j<c;j++)
{
if(mat[i][j]!='#'&&bst[j]!='.')
mat[i][j]='C';
}
bst=dp[i][bst].second;
}
cout<<"Case "<<cas++<<":\n";
for(int i=1;i<=r;i++)cout<<mat[i]<<endl;
cout<<endl;
}
}
จากคุณ : Kingzer [2010-09-27 13:43:49]  

118.173.100.230 ความคิดเห็น #28028 (จาก IP: 118.173.100.230)
บรรทัดนี้แปลกๆ
return "fuck";

แปลงเป็น flowchart เอาเองและกัน โค้ดไรกัน
จากคุณ : ล้อเล่นอะไร [2010-09-27 17:01:17]
ตอบกระทู้
  • ห้ามการโฆษณา หากต้องการติดต่อหาลูกค้า ติดต่อโฆษณาโดยตรงได้ที่ webmaster@sourcecode.in.th
  • ห้ามใช้คำหยาบและคำพูดที่ไม่เหมาะสม
  • ขอสงวนสิทธิหากตรวจพบ ข้อความที่ไม่เหมาะสม ข้อความนั้นจะถูกลบทันที
ชื่อ
อีเมล์
รายละเอียด

- - - - - - - - - - - - - - ผู้ให้การสนับสนุน- - - - - - - - - - - - - -

 
 
คลิปสอนเขียนโปรแกรม
เรียนเขียนโปรแกรมดอทเน็ต
เรียนเขียนโปรแกรมแอนดรอยด์
เรียนเขียนโปรแกรมเบล็คเบอร์รี่
เรียนเขียนโปรแกรมซี ซีพลัสพลัส
เรียนเขียนโปรแกรมจาวา
เรียนการใช้งานลินุกส์
เรียนการเขียนโปรแกรมวินโดว์โฟน
เรียนการเขียนโปรแกรมพีเฮชพี มายเอสคิวเอล
อัตราค่าโฆษณา
 
Tutorial
eVB Tutorial
ASP.NET Webmatrix Tutorial
J2ME Tutorial
C++  Tutorial
Java  Tutorial
PHP Tutorial
ASP Tutorial
 
แบบสำรวจ

Home - Article - Tutorial - Sourcecode - Dev Handbook - Search - WebBoard - Links - About Us

สงวนลิขสิทธิ์ ห้ามคัดลอก ทำซ้ำ แก้ไข ดัดแปลง ไม่ว่าในรูปแบบใด โดยไม่ได้รับอนุญาตเป็นลายลักษณ์อักษร
เลขทะเบียนพาณิชย์อิเล็กทรอนิกส์จากกระทรวงพาณิชย์: 7100503002000
Copyright 2001 SourceCode.in.th