← Home
```go
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	reader := bufio.NewReader(os.Stdin)
	writer := bufio.NewWriter(os.Stdout)
	defer writer.Flush()

	var n int
	fmt.Fscan(reader, &n)

	query := func(l, r int) (int, int) {
		fmt.Fprintf(writer, "? %d %d\n", l, r)
		writer.Flush()
		var x, f int
		fmt.Fscan(reader, &x, &f)
		return x, f
	}

	ans := make([]int, n+1)
	i := 1
	S := 1

	for i <= n {
		a_i, _ := query(i, i)

		if i == n {
			ans[i] = a_i
			break
		}

		v, f := query(i, n)
		if v == a_i {
			for j := i; j < i+f; j++ {
				ans[j] = a_i
			}
			S = f
			i += f
			continue
		}

		maxC := (n - i + 1) - f
		currentS := S
		if currentS > maxC {
			currentS = maxC
		}
		if currentS < 1 {
			currentS = 1
		}

		for {
			R := i + currentS - 1
			if R > i+maxC-1 {
				R = i + maxC - 1
			}

			var qV, qF int
			if R == i {
				qV, qF = a_i, 1
			} else {
				qV, qF = query(i, R)
			}

			if qV == a_i {
				if R == i+maxC-1 {
					for j := i; j < i+qF; j++ {
						ans[j] = a_i
					}
					S = qF
					i += qF
					break
				}
				if qF == currentS {
					currentS *= 2
				} else {
					for j := i; j < i+qF; j++ {
						ans[j] = a_i
					}
					S = qF
					i += qF
					break
				}
			} else {
				currentS -= qF
				if currentS < 1 {
					currentS = 1
				}
			}
		}
	}

	fmt.Fprintf(writer, "!")
	for j := 1; j <= n; j++ {
		fmt.Fprintf(writer, " %d", ans[j])
	}
	fmt.Fprintf(writer, "\n")
}
```