SlideShare a Scribd company logo
1 of 13
Download to read offline
Perancangan dan Analisis
Algoritme Lanjut
Agus Budi Raharjo
5109100164
Jurusan Teknik Informatika
Fakultas Teknologi Informasi
Institut Teknologi Sepuluh Nopember
Latihan
• SPOJ Problem Set (classical) 140 – The Loner
• SPOJ Problem Set (tutorial) 67 – Cutting out
• SPOJ Problem Set (tutorial) 404 – Scanner
SPOJ 140 The Loner
SPOJ Problem Set (classical)
140. The Loner
Problem code: LONER

The loner is a one-dimensional board game for a single player. The board is composed of squares arranged in a
single line, some of which initially have pawns on them. The player makes a move by jumping with a pawn over
a pawn on an adjacent field, to an empty square two fields to the right or left of its initial position. The pawn that
was jumped over is removed directly after the move, as illustrated below.

The game is considered won if exactly one pawn remains on the gaming board, and is lost if the player cannot
make a move.
Given the initial state of the gaming board, your task is to determine whether it is possible for the player to win
the game.
SPOJ 140 The Loner
Input
The input begins with the integer t, the number of test cases. Then t test cases follow. Each test cases begins with
the positive integer n <= 32000, denoting the size of the gaming board. The second and last line of the test case
description contains a sequence of n characters 0 or 1, without any white spaces. The i-th square of the board is
occupied by a pawn at the start of the game iff the i-th character of this sequence is 1.
Output
For each test case output the word yes if it is possible for the player to win the game for the presented starting
configuration, or the word no in the opposite case.
Example
Sample input:
2
7
0110011
6
111001

Sample output:
yes
no
SPOJ 140 The Loner
SPOJ 140 The Loner
SPOJ 140 The Loner
Langkah penyelesaian :
1. Hilangkan angka 0 di depan dan di belakang
permainan utama (0*L0*)
2. Untuk special case, definisikan
3. Cari persamaan antara array dengan teorema 1
SPOJ 140 The Loner
Dari teorema 1 didapat kemungkinan menang susunan
permainan (L; dengan 0*L0* ):
•
•
•
•
•
•
•
•
•
•

1
011
110
11(01)*00(10)*11
11(01)*00(11)+(10)*11
11(01)*(11) +00(10)*11
11(01)*(11)*1011(10)*11
11(01)*1101(11)*(10)*11
11(01)*(11)*01
10 (11)*(10)*11

Ket:
tanda WX*Y artinya WY, WXY, WXXY, WX.....Y
tanda WX+Y artinya WXY, WXXY, WXXXY, WX.....Y
SPOJ 140 The Loner
untuk mengubahnya menjadi bentuk kondisional (menggunakan
if), kita jabarkan dalam bentuk tree :

Ket : tanda garis bawah dan huruf “f” menandakan akhir array
SPOJ 140 The Loner
• Cont’d

Ket : tanda garis bawah dan huruf “f” menandakan akhir array
SPOJ 67 Cutting Out
SPOJ Problem Set (classical)
67. Cutting out
Problem code: CUTOUT
One has to cut out a number of rectangles from a paper square. The sides of each rectangle are to be parallel to the
sides of the square. Some rectangles can be already cut out. What is the largest area of a rectangle which can be cut
out from the remaining paper?
Illustration
Three rectangles have been cut out from the square 10x10 in the figure shown below. The area of the largest
rectangle that can be cut out from the remaining paper is 16. One of such rectangles is shown with a dashed line.

Task
Write a program that for each data set from a sequence of several data sets:
reads descriptions of a square and rectangles from the input,
computes the area of the largest rectangle which can be cut out from the remaining paper,
writes the result to output.
SPOJ 67 Cutting Out
Langkah penyelesaian :

1. Membuat Array persegi dengan sisi sesuai test
case dan membuat status “true”
2. Untuk setiap perpotongan, objek hasil
perpotongan berganti status menjadi “false”
3. Untuk mencari luas persegi terbesar cek tiap cell,
jika terdapat cell bernilai true, maka akan dicek
luas perseginya dan dibandingkan dengan luas
sebelumnya
SPOJ 67 Cutting Out
Alur pemeriksaan :
0 : posisi sekarang
1 : cek panjang (+1)
2 : cek lebar(sesuai dengan panjang)
3 : jika sudah membentuk persegi, index akan menuju ke cell 4
4 : cek panjang baru (+1)
5 : mencari lebar
6 : jika diketahui terdapat perpotongan, maka luas yang digunakan
adalah luas sebelumnya didapat dari index sekarang -1
dikuadratkan

More Related Content

Viewers also liked

Process technology 5109100164 5109100702
Process technology 5109100164 5109100702Process technology 5109100164 5109100702
Process technology 5109100164 5109100702Budi Raharjo
 
Analisa ud azam jaya
Analisa ud azam jayaAnalisa ud azam jaya
Analisa ud azam jayaBudi Raharjo
 
Instruksi mesin agus budi raharjo
Instruksi mesin agus budi raharjoInstruksi mesin agus budi raharjo
Instruksi mesin agus budi raharjoBudi Raharjo
 
Green computing pil
Green computing  pilGreen computing  pil
Green computing pilBudi Raharjo
 
Tugas pdhupl kelompok flixel
Tugas pdhupl kelompok flixelTugas pdhupl kelompok flixel
Tugas pdhupl kelompok flixelBudi Raharjo
 
Tugas 2 paal e agus budi raharjo 5109100164
Tugas 2 paal e agus budi raharjo 5109100164Tugas 2 paal e agus budi raharjo 5109100164
Tugas 2 paal e agus budi raharjo 5109100164Budi Raharjo
 
Algoritma floyd warshall dengan siklus negatif
Algoritma floyd warshall dengan siklus negatifAlgoritma floyd warshall dengan siklus negatif
Algoritma floyd warshall dengan siklus negatifBudi Raharjo
 
5112201905 memprediksi bidang minat mahasiswa menggunakan pca dan ann
5112201905 memprediksi bidang minat mahasiswa menggunakan pca dan ann5112201905 memprediksi bidang minat mahasiswa menggunakan pca dan ann
5112201905 memprediksi bidang minat mahasiswa menggunakan pca dan annBudi Raharjo
 
Gl01 spec pl - bid me - 5112201905
Gl01 spec pl - bid me - 5112201905Gl01 spec pl - bid me - 5112201905
Gl01 spec pl - bid me - 5112201905Budi Raharjo
 
Dokumentasi crack wifi
Dokumentasi crack wifiDokumentasi crack wifi
Dokumentasi crack wifiBudi Raharjo
 

Viewers also liked (12)

Process technology 5109100164 5109100702
Process technology 5109100164 5109100702Process technology 5109100164 5109100702
Process technology 5109100164 5109100702
 
Analisa ud azam jaya
Analisa ud azam jayaAnalisa ud azam jaya
Analisa ud azam jaya
 
Presentasi kwn
Presentasi kwnPresentasi kwn
Presentasi kwn
 
Instruksi mesin agus budi raharjo
Instruksi mesin agus budi raharjoInstruksi mesin agus budi raharjo
Instruksi mesin agus budi raharjo
 
Green computing pil
Green computing  pilGreen computing  pil
Green computing pil
 
Cloud computing
Cloud computingCloud computing
Cloud computing
 
Tugas pdhupl kelompok flixel
Tugas pdhupl kelompok flixelTugas pdhupl kelompok flixel
Tugas pdhupl kelompok flixel
 
Tugas 2 paal e agus budi raharjo 5109100164
Tugas 2 paal e agus budi raharjo 5109100164Tugas 2 paal e agus budi raharjo 5109100164
Tugas 2 paal e agus budi raharjo 5109100164
 
Algoritma floyd warshall dengan siklus negatif
Algoritma floyd warshall dengan siklus negatifAlgoritma floyd warshall dengan siklus negatif
Algoritma floyd warshall dengan siklus negatif
 
5112201905 memprediksi bidang minat mahasiswa menggunakan pca dan ann
5112201905 memprediksi bidang minat mahasiswa menggunakan pca dan ann5112201905 memprediksi bidang minat mahasiswa menggunakan pca dan ann
5112201905 memprediksi bidang minat mahasiswa menggunakan pca dan ann
 
Gl01 spec pl - bid me - 5112201905
Gl01 spec pl - bid me - 5112201905Gl01 spec pl - bid me - 5112201905
Gl01 spec pl - bid me - 5112201905
 
Dokumentasi crack wifi
Dokumentasi crack wifiDokumentasi crack wifi
Dokumentasi crack wifi
 

Similar to Tugas 1 paal e agus budi raharjo 5109100164

Similar to Tugas 1 paal e agus budi raharjo 5109100164 (16)

python.pptx
python.pptxpython.pptx
python.pptx
 
C++ projct
C++ projctC++ projct
C++ projct
 
Sol90
Sol90Sol90
Sol90
 
Sol90
Sol90Sol90
Sol90
 
Tic Tac Toe
Tic Tac ToeTic Tac Toe
Tic Tac Toe
 
0-miniproject sem 4 review 1(1)(2).pptx
0-miniproject sem 4 review 1(1)(2).pptx0-miniproject sem 4 review 1(1)(2).pptx
0-miniproject sem 4 review 1(1)(2).pptx
 
Artificial intelligence - python
Artificial intelligence - pythonArtificial intelligence - python
Artificial intelligence - python
 
Mine sweeper
Mine sweeperMine sweeper
Mine sweeper
 
UNIT-1_CSA.pdf
UNIT-1_CSA.pdfUNIT-1_CSA.pdf
UNIT-1_CSA.pdf
 
lagrange and newton divided differences.ppt
lagrange and newton divided differences.pptlagrange and newton divided differences.ppt
lagrange and newton divided differences.ppt
 
Binary operations
 Binary operations Binary operations
Binary operations
 
3rd Semester Civil Engineering (2013-December) Question Papers
3rd Semester Civil Engineering (2013-December) Question Papers3rd Semester Civil Engineering (2013-December) Question Papers
3rd Semester Civil Engineering (2013-December) Question Papers
 
100 Combinatorics Problems (With Solutions)
100 Combinatorics Problems (With Solutions)100 Combinatorics Problems (With Solutions)
100 Combinatorics Problems (With Solutions)
 
Android application - Tic Tac Toe
Android application - Tic Tac ToeAndroid application - Tic Tac Toe
Android application - Tic Tac Toe
 
Upload
UploadUpload
Upload
 
Coordinates y3 y4
Coordinates y3 y4Coordinates y3 y4
Coordinates y3 y4
 

More from Budi Raharjo

5112201905 house of quality
5112201905 house of quality5112201905 house of quality
5112201905 house of qualityBudi Raharjo
 
Tugas framework j2 ee beda app session page
Tugas framework j2 ee beda app session pageTugas framework j2 ee beda app session page
Tugas framework j2 ee beda app session pageBudi Raharjo
 
Penggunaan network address translation
Penggunaan network address translationPenggunaan network address translation
Penggunaan network address translationBudi Raharjo
 
Paper cloud computing br
Paper cloud computing brPaper cloud computing br
Paper cloud computing brBudi Raharjo
 
Protocol lan 5109100164
Protocol lan 5109100164Protocol lan 5109100164
Protocol lan 5109100164Budi Raharjo
 
Peranan pembelajaran elektronik
Peranan pembelajaran elektronikPeranan pembelajaran elektronik
Peranan pembelajaran elektronikBudi Raharjo
 
Perbedaan antar computer filesystem 5109100164
Perbedaan antar computer filesystem 5109100164Perbedaan antar computer filesystem 5109100164
Perbedaan antar computer filesystem 5109100164Budi Raharjo
 
Makalah pengantar basis data 5109100164
Makalah pengantar basis data 5109100164Makalah pengantar basis data 5109100164
Makalah pengantar basis data 5109100164Budi Raharjo
 
5109100023 makalah
5109100023 makalah5109100023 makalah
5109100023 makalahBudi Raharjo
 

More from Budi Raharjo (13)

5112201905 house of quality
5112201905 house of quality5112201905 house of quality
5112201905 house of quality
 
Tugas framework j2 ee beda app session page
Tugas framework j2 ee beda app session pageTugas framework j2 ee beda app session page
Tugas framework j2 ee beda app session page
 
Review game
Review gameReview game
Review game
 
Laporan topologi
Laporan topologiLaporan topologi
Laporan topologi
 
Penggunaan network address translation
Penggunaan network address translationPenggunaan network address translation
Penggunaan network address translation
 
Paper cloud computing br
Paper cloud computing brPaper cloud computing br
Paper cloud computing br
 
Protocol lan 5109100164
Protocol lan 5109100164Protocol lan 5109100164
Protocol lan 5109100164
 
Peranan pembelajaran elektronik
Peranan pembelajaran elektronikPeranan pembelajaran elektronik
Peranan pembelajaran elektronik
 
Perbedaan antar computer filesystem 5109100164
Perbedaan antar computer filesystem 5109100164Perbedaan antar computer filesystem 5109100164
Perbedaan antar computer filesystem 5109100164
 
Makalah pengantar basis data 5109100164
Makalah pengantar basis data 5109100164Makalah pengantar basis data 5109100164
Makalah pengantar basis data 5109100164
 
Agama
AgamaAgama
Agama
 
5109100023 makalah
5109100023 makalah5109100023 makalah
5109100023 makalah
 
desain server
desain serverdesain server
desain server
 

Recently uploaded

The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraDeakin University
 
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024BookNet Canada
 
APIForce Zurich 5 April Automation LPDG
APIForce Zurich 5 April  Automation LPDGAPIForce Zurich 5 April  Automation LPDG
APIForce Zurich 5 April Automation LPDGMarianaLemus7
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphNeo4j
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 

Recently uploaded (20)

The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning era
 
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
 
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptxVulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
 
APIForce Zurich 5 April Automation LPDG
APIForce Zurich 5 April  Automation LPDGAPIForce Zurich 5 April  Automation LPDG
APIForce Zurich 5 April Automation LPDG
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
The transition to renewables in India.pdf
The transition to renewables in India.pdfThe transition to renewables in India.pdf
The transition to renewables in India.pdf
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 

Tugas 1 paal e agus budi raharjo 5109100164

  • 1. Perancangan dan Analisis Algoritme Lanjut Agus Budi Raharjo 5109100164 Jurusan Teknik Informatika Fakultas Teknologi Informasi Institut Teknologi Sepuluh Nopember
  • 2. Latihan • SPOJ Problem Set (classical) 140 – The Loner • SPOJ Problem Set (tutorial) 67 – Cutting out • SPOJ Problem Set (tutorial) 404 – Scanner
  • 3. SPOJ 140 The Loner SPOJ Problem Set (classical) 140. The Loner Problem code: LONER The loner is a one-dimensional board game for a single player. The board is composed of squares arranged in a single line, some of which initially have pawns on them. The player makes a move by jumping with a pawn over a pawn on an adjacent field, to an empty square two fields to the right or left of its initial position. The pawn that was jumped over is removed directly after the move, as illustrated below. The game is considered won if exactly one pawn remains on the gaming board, and is lost if the player cannot make a move. Given the initial state of the gaming board, your task is to determine whether it is possible for the player to win the game.
  • 4. SPOJ 140 The Loner Input The input begins with the integer t, the number of test cases. Then t test cases follow. Each test cases begins with the positive integer n <= 32000, denoting the size of the gaming board. The second and last line of the test case description contains a sequence of n characters 0 or 1, without any white spaces. The i-th square of the board is occupied by a pawn at the start of the game iff the i-th character of this sequence is 1. Output For each test case output the word yes if it is possible for the player to win the game for the presented starting configuration, or the word no in the opposite case. Example Sample input: 2 7 0110011 6 111001 Sample output: yes no
  • 5. SPOJ 140 The Loner
  • 6. SPOJ 140 The Loner
  • 7. SPOJ 140 The Loner Langkah penyelesaian : 1. Hilangkan angka 0 di depan dan di belakang permainan utama (0*L0*) 2. Untuk special case, definisikan 3. Cari persamaan antara array dengan teorema 1
  • 8. SPOJ 140 The Loner Dari teorema 1 didapat kemungkinan menang susunan permainan (L; dengan 0*L0* ): • • • • • • • • • • 1 011 110 11(01)*00(10)*11 11(01)*00(11)+(10)*11 11(01)*(11) +00(10)*11 11(01)*(11)*1011(10)*11 11(01)*1101(11)*(10)*11 11(01)*(11)*01 10 (11)*(10)*11 Ket: tanda WX*Y artinya WY, WXY, WXXY, WX.....Y tanda WX+Y artinya WXY, WXXY, WXXXY, WX.....Y
  • 9. SPOJ 140 The Loner untuk mengubahnya menjadi bentuk kondisional (menggunakan if), kita jabarkan dalam bentuk tree : Ket : tanda garis bawah dan huruf “f” menandakan akhir array
  • 10. SPOJ 140 The Loner • Cont’d Ket : tanda garis bawah dan huruf “f” menandakan akhir array
  • 11. SPOJ 67 Cutting Out SPOJ Problem Set (classical) 67. Cutting out Problem code: CUTOUT One has to cut out a number of rectangles from a paper square. The sides of each rectangle are to be parallel to the sides of the square. Some rectangles can be already cut out. What is the largest area of a rectangle which can be cut out from the remaining paper? Illustration Three rectangles have been cut out from the square 10x10 in the figure shown below. The area of the largest rectangle that can be cut out from the remaining paper is 16. One of such rectangles is shown with a dashed line. Task Write a program that for each data set from a sequence of several data sets: reads descriptions of a square and rectangles from the input, computes the area of the largest rectangle which can be cut out from the remaining paper, writes the result to output.
  • 12. SPOJ 67 Cutting Out Langkah penyelesaian : 1. Membuat Array persegi dengan sisi sesuai test case dan membuat status “true” 2. Untuk setiap perpotongan, objek hasil perpotongan berganti status menjadi “false” 3. Untuk mencari luas persegi terbesar cek tiap cell, jika terdapat cell bernilai true, maka akan dicek luas perseginya dan dibandingkan dengan luas sebelumnya
  • 13. SPOJ 67 Cutting Out Alur pemeriksaan : 0 : posisi sekarang 1 : cek panjang (+1) 2 : cek lebar(sesuai dengan panjang) 3 : jika sudah membentuk persegi, index akan menuju ke cell 4 4 : cek panjang baru (+1) 5 : mencari lebar 6 : jika diketahui terdapat perpotongan, maka luas yang digunakan adalah luas sebelumnya didapat dari index sekarang -1 dikuadratkan